vspk.v3_2 module
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015, Alcatel-Lucent Inc
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
__all__ = ['NUVSDSession', 'NUAddressRange', 'NUAggregateMetadata', 'NUAlarm', 'NUApp', 'NUApplicationService', 'NUAutoDiscoveredGateway', 'NUBGPPeer', 'NUBootstrap', 'NUBootstrapActivation', 'NUBridgeInterface', 'NUCertificate', 'NUCloudMgmtSystem', 'NUDHCPOption', 'NUDiskStat', 'NUDomain', 'NUDomainFIPAclTemplate', 'NUDomainFIPAclTemplateEntry', 'NUDomainTemplate', 'NUDSCPForwardingClassMapping', 'NUDSCPForwardingClassTable', 'NUEgressACLEntryTemplate', 'NUEgressACLTemplate', 'NUEgressQOSPolicy', 'NUEndPoint', 'NUEnterpriseNetwork', 'NUEnterprisePermission', 'NUEnterpriseProfile', 'NUEnterpriseSecuredData', 'NUEnterpriseSecurity', 'NUEventLog', 'NUExternalAppService', 'NUExternalService', 'NUFloatingIp', 'NUFloatingIPACLTemplate', 'NUFloatingIPACLTemplateEntry', 'NUFlow', 'NUFlowForwardingPolicy', 'NUFlowSecurityPolicy', 'NUGateway', 'NUGatewaySecuredData', 'NUGatewaySecurity', 'NUGatewaySecurityProfile', 'NUGatewayTemplate', 'NUGlobalMetadata', 'NUGroup', 'NUGroupKeyEncryptionProfile', 'NUHostInterface', 'NUHSC', 'NUInfrastructureConfig', 'NUInfrastructureGatewayProfile', 'NUInfrastructurePortProfile', 'NUInfrastructureVscProfile', 'NUIngressACLEntryTemplate', 'NUIngressACLTemplate', 'NUIngressAdvFwdEntryTemplate', 'NUIngressAdvFwdTemplate', 'NUIngressExternalServiceTemplate', 'NUIngressExternalServiceTemplateEntry', 'NUIPReservation', 'NUJob', 'NUKeyServerMember', 'NUKeyServerMonitor', 'NUKeyServerMonitorEncryptedSeed', 'NUKeyServerMonitorSeed', 'NUKeyServerMonitorSEK', 'NUL2Domain', 'NUL2DomainTemplate', 'NULDAPConfiguration', 'NULicense', 'NULocation', 'NUMe', 'NUMetadata', 'NUMetadataTag', 'NUMirrorDestination', 'NUMonitoringPort', 'NUMultiCastChannelMap', 'NUMultiCastList', 'NUMultiCastRange', 'NUMultiNICVPort', 'NUNATMapEntry', 'NUNetworkLayout', 'NUNetworkMacroGroup', 'NUNSGateway', 'NUNSGatewayTemplate', 'NUNSPort', 'NUNSPortStaticConfiguration', 'NUNSPortTemplate', 'NUNSRedundantGatewayGroup', 'NUPATNATPool', 'NUPermission', 'NUPolicyDecision', 'NUPolicyGroup', 'NUPolicyGroupTemplate', 'NUPort', 'NUPortTemplate', 'NUPublicNetworkMacro', 'NUQOS', 'NURateLimiter', 'NURedirectionTarget', 'NURedirectionTargetTemplate', 'NURedundancyGroup', 'NURedundantPort', 'NUSharedNetworkResource', 'NUSiteInfo', 'NUStaticRoute', 'NUStatistics', 'NUStatisticsPolicy', 'NUStatsCollectorInfo', 'NUSubnet', 'NUSubnetTemplate', 'NUSystemConfig', 'NUTCA', 'NUTier', 'NUUplinkRD', 'NUUser', 'NUVCenter', 'NUVCenterCluster', 'NUVCenterDataCenter', 'NUVCenterEAMConfig', 'NUVCenterHypervisor', 'NUVCenterVRSConfig', 'NUVirtualIP', 'NUVLAN', 'NUVLANTemplate', 'NUVM', 'NUVMInterface', 'NUVMResync', 'NUVPNConnection', 'NUVPort', 'NUVPortMirror', 'NUVRS', 'NUVRSAddressRange', 'NUVSC', 'NUVSD', 'NUVSDComponent', 'NUVsgRedundantPort', 'NUVSP', 'NUWANService', 'NUZone', 'NUZoneTemplate']
from .nuaddressrange import NUAddressRange
from .nuaggregatemetadata import NUAggregateMetadata
from .nualarm import NUAlarm
from .nuapp import NUApp
from .nuapplicationservice import NUApplicationService
from .nuautodiscoveredgateway import NUAutoDiscoveredGateway
from .nubgppeer import NUBGPPeer
from .nubootstrap import NUBootstrap
from .nubootstrapactivation import NUBootstrapActivation
from .nubridgeinterface import NUBridgeInterface
from .nucertificate import NUCertificate
from .nucloudmgmtsystem import NUCloudMgmtSystem
from .nudhcpoption import NUDHCPOption
from .nudiskstat import NUDiskStat
from .nudomain import NUDomain
from .nudomainfipacltemplate import NUDomainFIPAclTemplate
from .nudomainfipacltemplateentry import NUDomainFIPAclTemplateEntry
from .nudomaintemplate import NUDomainTemplate
from .nudscpforwardingclassmapping import NUDSCPForwardingClassMapping
from .nudscpforwardingclasstable import NUDSCPForwardingClassTable
from .nuegressaclentrytemplate import NUEgressACLEntryTemplate
from .nuegressacltemplate import NUEgressACLTemplate
from .nuegressqospolicy import NUEgressQOSPolicy
from .nuendpoint import NUEndPoint
from .nuenterprisenetwork import NUEnterpriseNetwork
from .nuenterprisepermission import NUEnterprisePermission
from .nuenterpriseprofile import NUEnterpriseProfile
from .nuenterprisesecureddata import NUEnterpriseSecuredData
from .nuenterprisesecurity import NUEnterpriseSecurity
from .nueventlog import NUEventLog
from .nuexternalappservice import NUExternalAppService
from .nuexternalservice import NUExternalService
from .nufloatingip import NUFloatingIp
from .nufloatingipacltemplate import NUFloatingIPACLTemplate
from .nufloatingipacltemplateentry import NUFloatingIPACLTemplateEntry
from .nuflow import NUFlow
from .nuflowforwardingpolicy import NUFlowForwardingPolicy
from .nuflowsecuritypolicy import NUFlowSecurityPolicy
from .nugateway import NUGateway
from .nugatewaysecureddata import NUGatewaySecuredData
from .nugatewaysecurity import NUGatewaySecurity
from .nugatewaysecurityprofile import NUGatewaySecurityProfile
from .nugatewaytemplate import NUGatewayTemplate
from .nuglobalmetadata import NUGlobalMetadata
from .nugroup import NUGroup
from .nugroupkeyencryptionprofile import NUGroupKeyEncryptionProfile
from .nuhostinterface import NUHostInterface
from .nuhsc import NUHSC
from .nuinfrastructureconfig import NUInfrastructureConfig
from .nuinfrastructuregatewayprofile import NUInfrastructureGatewayProfile
from .nuinfrastructureportprofile import NUInfrastructurePortProfile
from .nuinfrastructurevscprofile import NUInfrastructureVscProfile
from .nuingressaclentrytemplate import NUIngressACLEntryTemplate
from .nuingressacltemplate import NUIngressACLTemplate
from .nuingressadvfwdentrytemplate import NUIngressAdvFwdEntryTemplate
from .nuingressadvfwdtemplate import NUIngressAdvFwdTemplate
from .nuingressexternalservicetemplate import NUIngressExternalServiceTemplate
from .nuingressexternalservicetemplateentry import NUIngressExternalServiceTemplateEntry
from .nuipreservation import NUIPReservation
from .nujob import NUJob
from .nukeyservermember import NUKeyServerMember
from .nukeyservermonitor import NUKeyServerMonitor
from .nukeyservermonitorencryptedseed import NUKeyServerMonitorEncryptedSeed
from .nukeyservermonitorseed import NUKeyServerMonitorSeed
from .nukeyservermonitorsek import NUKeyServerMonitorSEK
from .nul2domain import NUL2Domain
from .nul2domaintemplate import NUL2DomainTemplate
from .nuldapconfiguration import NULDAPConfiguration
from .nulicense import NULicense
from .nulocation import NULocation
from .nume import NUMe
from .numetadata import NUMetadata
from .numetadatatag import NUMetadataTag
from .numirrordestination import NUMirrorDestination
from .numonitoringport import NUMonitoringPort
from .numulticastchannelmap import NUMultiCastChannelMap
from .numulticastlist import NUMultiCastList
from .numulticastrange import NUMultiCastRange
from .numultinicvport import NUMultiNICVPort
from .nunatmapentry import NUNATMapEntry
from .nunetworklayout import NUNetworkLayout
from .nunetworkmacrogroup import NUNetworkMacroGroup
from .nunsgateway import NUNSGateway
from .nunsgatewaytemplate import NUNSGatewayTemplate
from .nunsport import NUNSPort
from .nunsportstaticconfiguration import NUNSPortStaticConfiguration
from .nunsporttemplate import NUNSPortTemplate
from .nunsredundantgatewaygroup import NUNSRedundantGatewayGroup
from .nupatnatpool import NUPATNATPool
from .nupermission import NUPermission
from .nupolicydecision import NUPolicyDecision
from .nupolicygroup import NUPolicyGroup
from .nupolicygrouptemplate import NUPolicyGroupTemplate
from .nuport import NUPort
from .nuporttemplate import NUPortTemplate
from .nupublicnetworkmacro import NUPublicNetworkMacro
from .nuqos import NUQOS
from .nuratelimiter import NURateLimiter
from .nuredirectiontarget import NURedirectionTarget
from .nuredirectiontargettemplate import NURedirectionTargetTemplate
from .nuredundancygroup import NURedundancyGroup
from .nuredundantport import NURedundantPort
from .nusharednetworkresource import NUSharedNetworkResource
from .nusiteinfo import NUSiteInfo
from .nustaticroute import NUStaticRoute
from .nustatistics import NUStatistics
from .nustatisticspolicy import NUStatisticsPolicy
from .nustatscollectorinfo import NUStatsCollectorInfo
from .nusubnet import NUSubnet
from .nusubnettemplate import NUSubnetTemplate
from .nusystemconfig import NUSystemConfig
from .nutca import NUTCA
from .nutier import NUTier
from .nuuplinkrd import NUUplinkRD
from .nuuser import NUUser
from .nuvcenter import NUVCenter
from .nuvcentercluster import NUVCenterCluster
from .nuvcenterdatacenter import NUVCenterDataCenter
from .nuvcentereamconfig import NUVCenterEAMConfig
from .nuvcenterhypervisor import NUVCenterHypervisor
from .nuvcentervrsconfig import NUVCenterVRSConfig
from .nuvirtualip import NUVirtualIP
from .nuvlan import NUVLAN
from .nuvlantemplate import NUVLANTemplate
from .nuvm import NUVM
from .nuvminterface import NUVMInterface
from .nuvmresync import NUVMResync
from .nuvpnconnection import NUVPNConnection
from .nuvport import NUVPort
from .nuvportmirror import NUVPortMirror
from .nuvrs import NUVRS
from .nuvrsaddressrange import NUVRSAddressRange
from .nuvsc import NUVSC
from .nuvsd import NUVSD
from .nuvsdcomponent import NUVSDComponent
from .nuvsgredundantport import NUVsgRedundantPort
from .nuvsp import NUVSP
from .nuwanservice import NUWANService
from .nuzone import NUZone
from .nuzonetemplate import NUZoneTemplate
from .nuvsdsession import NUVSDSession
from .sdkinfo import SDKInfo
def __setup_bambou():
""" Avoid having bad behavior when using importlib.import_module method
"""
import pkg_resources
from bambou import BambouConfig, NURESTModelController
default_attrs = pkg_resources.resource_filename(__name__, '/resources/attrs_defaults.ini')
BambouConfig.set_default_values_config_file(default_attrs)
NURESTModelController.register_model(NUAddressRange)
NURESTModelController.register_model(NUAggregateMetadata)
NURESTModelController.register_model(NUAlarm)
NURESTModelController.register_model(NUApp)
NURESTModelController.register_model(NUApplicationService)
NURESTModelController.register_model(NUAutoDiscoveredGateway)
NURESTModelController.register_model(NUBGPPeer)
NURESTModelController.register_model(NUBootstrap)
NURESTModelController.register_model(NUBootstrapActivation)
NURESTModelController.register_model(NUBridgeInterface)
NURESTModelController.register_model(NUCertificate)
NURESTModelController.register_model(NUCloudMgmtSystem)
NURESTModelController.register_model(NUDHCPOption)
NURESTModelController.register_model(NUDiskStat)
NURESTModelController.register_model(NUDomain)
NURESTModelController.register_model(NUDomainFIPAclTemplate)
NURESTModelController.register_model(NUDomainFIPAclTemplateEntry)
NURESTModelController.register_model(NUDomainTemplate)
NURESTModelController.register_model(NUDSCPForwardingClassMapping)
NURESTModelController.register_model(NUDSCPForwardingClassTable)
NURESTModelController.register_model(NUEgressACLEntryTemplate)
NURESTModelController.register_model(NUEgressACLTemplate)
NURESTModelController.register_model(NUEgressQOSPolicy)
NURESTModelController.register_model(NUEndPoint)
NURESTModelController.register_model(NUEnterpriseNetwork)
NURESTModelController.register_model(NUEnterprisePermission)
NURESTModelController.register_model(NUEnterpriseProfile)
NURESTModelController.register_model(NUEnterpriseSecuredData)
NURESTModelController.register_model(NUEnterpriseSecurity)
NURESTModelController.register_model(NUEventLog)
NURESTModelController.register_model(NUExternalAppService)
NURESTModelController.register_model(NUExternalService)
NURESTModelController.register_model(NUFloatingIp)
NURESTModelController.register_model(NUFloatingIPACLTemplate)
NURESTModelController.register_model(NUFloatingIPACLTemplateEntry)
NURESTModelController.register_model(NUFlow)
NURESTModelController.register_model(NUFlowForwardingPolicy)
NURESTModelController.register_model(NUFlowSecurityPolicy)
NURESTModelController.register_model(NUGateway)
NURESTModelController.register_model(NUGatewaySecuredData)
NURESTModelController.register_model(NUGatewaySecurity)
NURESTModelController.register_model(NUGatewaySecurityProfile)
NURESTModelController.register_model(NUGatewayTemplate)
NURESTModelController.register_model(NUGlobalMetadata)
NURESTModelController.register_model(NUGroup)
NURESTModelController.register_model(NUGroupKeyEncryptionProfile)
NURESTModelController.register_model(NUHostInterface)
NURESTModelController.register_model(NUHSC)
NURESTModelController.register_model(NUInfrastructureConfig)
NURESTModelController.register_model(NUInfrastructureGatewayProfile)
NURESTModelController.register_model(NUInfrastructurePortProfile)
NURESTModelController.register_model(NUInfrastructureVscProfile)
NURESTModelController.register_model(NUIngressACLEntryTemplate)
NURESTModelController.register_model(NUIngressACLTemplate)
NURESTModelController.register_model(NUIngressAdvFwdEntryTemplate)
NURESTModelController.register_model(NUIngressAdvFwdTemplate)
NURESTModelController.register_model(NUIngressExternalServiceTemplate)
NURESTModelController.register_model(NUIngressExternalServiceTemplateEntry)
NURESTModelController.register_model(NUIPReservation)
NURESTModelController.register_model(NUJob)
NURESTModelController.register_model(NUKeyServerMember)
NURESTModelController.register_model(NUKeyServerMonitor)
NURESTModelController.register_model(NUKeyServerMonitorEncryptedSeed)
NURESTModelController.register_model(NUKeyServerMonitorSeed)
NURESTModelController.register_model(NUKeyServerMonitorSEK)
NURESTModelController.register_model(NUL2Domain)
NURESTModelController.register_model(NUL2DomainTemplate)
NURESTModelController.register_model(NULDAPConfiguration)
NURESTModelController.register_model(NULicense)
NURESTModelController.register_model(NULocation)
NURESTModelController.register_model(NUMe)
NURESTModelController.register_model(NUMetadata)
NURESTModelController.register_model(NUMetadataTag)
NURESTModelController.register_model(NUMirrorDestination)
NURESTModelController.register_model(NUMonitoringPort)
NURESTModelController.register_model(NUMultiCastChannelMap)
NURESTModelController.register_model(NUMultiCastList)
NURESTModelController.register_model(NUMultiCastRange)
NURESTModelController.register_model(NUMultiNICVPort)
NURESTModelController.register_model(NUNATMapEntry)
NURESTModelController.register_model(NUNetworkLayout)
NURESTModelController.register_model(NUNetworkMacroGroup)
NURESTModelController.register_model(NUNSGateway)
NURESTModelController.register_model(NUNSGatewayTemplate)
NURESTModelController.register_model(NUNSPort)
NURESTModelController.register_model(NUNSPortStaticConfiguration)
NURESTModelController.register_model(NUNSPortTemplate)
NURESTModelController.register_model(NUNSRedundantGatewayGroup)
NURESTModelController.register_model(NUPATNATPool)
NURESTModelController.register_model(NUPermission)
NURESTModelController.register_model(NUPolicyDecision)
NURESTModelController.register_model(NUPolicyGroup)
NURESTModelController.register_model(NUPolicyGroupTemplate)
NURESTModelController.register_model(NUPort)
NURESTModelController.register_model(NUPortTemplate)
NURESTModelController.register_model(NUPublicNetworkMacro)
NURESTModelController.register_model(NUQOS)
NURESTModelController.register_model(NURateLimiter)
NURESTModelController.register_model(NURedirectionTarget)
NURESTModelController.register_model(NURedirectionTargetTemplate)
NURESTModelController.register_model(NURedundancyGroup)
NURESTModelController.register_model(NURedundantPort)
NURESTModelController.register_model(NUSharedNetworkResource)
NURESTModelController.register_model(NUSiteInfo)
NURESTModelController.register_model(NUStaticRoute)
NURESTModelController.register_model(NUStatistics)
NURESTModelController.register_model(NUStatisticsPolicy)
NURESTModelController.register_model(NUStatsCollectorInfo)
NURESTModelController.register_model(NUSubnet)
NURESTModelController.register_model(NUSubnetTemplate)
NURESTModelController.register_model(NUSystemConfig)
NURESTModelController.register_model(NUTCA)
NURESTModelController.register_model(NUTier)
NURESTModelController.register_model(NUUplinkRD)
NURESTModelController.register_model(NUUser)
NURESTModelController.register_model(NUVCenter)
NURESTModelController.register_model(NUVCenterCluster)
NURESTModelController.register_model(NUVCenterDataCenter)
NURESTModelController.register_model(NUVCenterEAMConfig)
NURESTModelController.register_model(NUVCenterHypervisor)
NURESTModelController.register_model(NUVCenterVRSConfig)
NURESTModelController.register_model(NUVirtualIP)
NURESTModelController.register_model(NUVLAN)
NURESTModelController.register_model(NUVLANTemplate)
NURESTModelController.register_model(NUVM)
NURESTModelController.register_model(NUVMInterface)
NURESTModelController.register_model(NUVMResync)
NURESTModelController.register_model(NUVPNConnection)
NURESTModelController.register_model(NUVPort)
NURESTModelController.register_model(NUVPortMirror)
NURESTModelController.register_model(NUVRS)
NURESTModelController.register_model(NUVRSAddressRange)
NURESTModelController.register_model(NUVSC)
NURESTModelController.register_model(NUVSD)
NURESTModelController.register_model(NUVSDComponent)
NURESTModelController.register_model(NUVsgRedundantPort)
NURESTModelController.register_model(NUVSP)
NURESTModelController.register_model(NUWANService)
NURESTModelController.register_model(NUZone)
NURESTModelController.register_model(NUZoneTemplate)
__setup_bambou()
Classes
class NUAddressRange
Represents a AddressRange in the VSD
Notes: This is the definition of a Address Range associated with a Network.
class NUAddressRange(NURESTObject):
""" Represents a AddressRange in the VSD
Notes:
This is the definition of a Address Range associated with a Network.
"""
__rest_name__ = "addressrange"
__resource_name__ = "addressranges"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_DHCP_POOL_TYPE_BRIDGE = "BRIDGE"
CONST_DHCP_POOL_TYPE_HOST = "HOST"
def __init__(self, **kwargs):
""" Initializes a AddressRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> addressrange = NUAddressRange(id=u'xxxx-xxx-xxx-xxx', name=u'AddressRange')
>>> addressrange = NUAddressRange(data=my_dict)
"""
super(NUAddressRange, self).__init__()
# Read/Write Attributes
self._dhcp_pool_type = None
self._last_updated_by = None
self._max_address = None
self._min_address = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="dhcp_pool_type", remote_name="DHCPPoolType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BRIDGE', u'HOST'])
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_address", remote_name="maxAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="min_address", remote_name="minAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dhcp_pool_type(self):
""" Get dhcp_pool_type value.
Notes:
DHCPPoolType is an enum that indicates if the DHCP Pool is for HOST/BRIDGE.
This attribute is named `DHCPPoolType` in VSD API.
"""
return self._dhcp_pool_type
@dhcp_pool_type.setter
def dhcp_pool_type(self, value):
""" Set dhcp_pool_type value.
Notes:
DHCPPoolType is an enum that indicates if the DHCP Pool is for HOST/BRIDGE.
This attribute is named `DHCPPoolType` in VSD API.
"""
self._dhcp_pool_type = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def max_address(self):
""" Get max_address value.
Notes:
Higest address in the address range
This attribute is named `maxAddress` in VSD API.
"""
return self._max_address
@max_address.setter
def max_address(self, value):
""" Set max_address value.
Notes:
Higest address in the address range
This attribute is named `maxAddress` in VSD API.
"""
self._max_address = value
@property
def min_address(self):
""" Get min_address value.
Notes:
Lowest address in the address range
This attribute is named `minAddress` in VSD API.
"""
return self._min_address
@min_address.setter
def min_address(self, value):
""" Set min_address value.
Notes:
Lowest address in the address range
This attribute is named `minAddress` in VSD API.
"""
self._min_address = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUAddressRange
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_DHCP_POOL_TYPE_BRIDGE
var CONST_DHCP_POOL_TYPE_HOST
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var dhcp_pool_type
Get dhcp_pool_type value.
Notes: DHCPPoolType is an enum that indicates if the DHCP Pool is for HOST/BRIDGE.
This attribute is named `DHCPPoolType` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var max_address
Get max_address value.
Notes: Higest address in the address range
This attribute is named `maxAddress` in VSD API.
var metadatas
var min_address
Get min_address value.
Notes: Lowest address in the address range
This attribute is named `minAddress` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a AddressRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> addressrange = NUAddressRange(id=u'xxxx-xxx-xxx-xxx', name=u'AddressRange') >>> addressrange = NUAddressRange(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a AddressRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> addressrange = NUAddressRange(id=u'xxxx-xxx-xxx-xxx', name=u'AddressRange')
>>> addressrange = NUAddressRange(data=my_dict)
"""
super(NUAddressRange, self).__init__()
# Read/Write Attributes
self._dhcp_pool_type = None
self._last_updated_by = None
self._max_address = None
self._min_address = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="dhcp_pool_type", remote_name="DHCPPoolType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BRIDGE', u'HOST'])
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_address", remote_name="maxAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="min_address", remote_name="minAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUAggregateMetadata
Represents a AggregateMetadata in the VSD
Notes: Metadata associated to a entity
class NUAggregateMetadata(NURESTObject):
""" Represents a AggregateMetadata in the VSD
Notes:
Metadata associated to a entity
"""
__rest_name__ = "aggregatemetadata"
__resource_name__ = "aggregatemetadatas"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a AggregateMetadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> aggregatemetadata = NUAggregateMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'AggregateMetadata')
>>> aggregatemetadata = NUAggregateMetadata(data=my_dict)
"""
super(NUAggregateMetadata, self).__init__()
# Read/Write Attributes
self._name = None
self._description = None
self._metadata_tag_ids = None
self._network_notification_disabled = None
self._blob = None
self._global_metadata = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_tag_ids", remote_name="metadataTagIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_notification_disabled", remote_name="networkNotificationDisabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="blob", remote_name="blob", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="global_metadata", remote_name="global", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Metadata.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Metadata.
"""
self._name = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Metadata.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Metadata.
"""
self._description = value
@property
def metadata_tag_ids(self):
""" Get metadata_tag_ids value.
Notes:
Metadata tag IDs associated with this metadata. You can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
"""
return self._metadata_tag_ids
@metadata_tag_ids.setter
def metadata_tag_ids(self, value):
""" Set metadata_tag_ids value.
Notes:
Metadata tag IDs associated with this metadata. You can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
"""
self._metadata_tag_ids = value
@property
def network_notification_disabled(self):
""" Get network_notification_disabled value.
Notes:
Specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
"""
return self._network_notification_disabled
@network_notification_disabled.setter
def network_notification_disabled(self, value):
""" Set network_notification_disabled value.
Notes:
Specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
"""
self._network_notification_disabled = value
@property
def blob(self):
""" Get blob value.
Notes:
Metadata that describes about the entity attached to it.
"""
return self._blob
@blob.setter
def blob(self, value):
""" Set blob value.
Notes:
Metadata that describes about the entity attached to it.
"""
self._blob = value
@property
def global_metadata(self):
""" Get global_metadata value.
Notes:
Specifies whether the metadata is global or local
This attribute is named `global` in VSD API.
"""
return self._global_metadata
@global_metadata.setter
def global_metadata(self, value):
""" Set global_metadata value.
Notes:
Specifies whether the metadata is global or local
This attribute is named `global` in VSD API.
"""
self._global_metadata = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUAggregateMetadata
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var blob
Get blob value.
Notes: Metadata that describes about the entity attached to it.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the Metadata.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadata
Get global_metadata value.
Notes: Specifies whether the metadata is global or local
This attribute is named `global` in VSD API.
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_tag_ids
Get metadata_tag_ids value.
Notes: Metadata tag IDs associated with this metadata. You can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
var name
Get name value.
Notes: Name of the Metadata.
var network_notification_disabled
Get network_notification_disabled value.
Notes: Specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a AggregateMetadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> aggregatemetadata = NUAggregateMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'AggregateMetadata') >>> aggregatemetadata = NUAggregateMetadata(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a AggregateMetadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> aggregatemetadata = NUAggregateMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'AggregateMetadata')
>>> aggregatemetadata = NUAggregateMetadata(data=my_dict)
"""
super(NUAggregateMetadata, self).__init__()
# Read/Write Attributes
self._name = None
self._description = None
self._metadata_tag_ids = None
self._network_notification_disabled = None
self._blob = None
self._global_metadata = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_tag_ids", remote_name="metadataTagIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_notification_disabled", remote_name="networkNotificationDisabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="blob", remote_name="blob", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="global_metadata", remote_name="global", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUAlarm
Represents a Alarm in the VSD
Notes: The alarm API allows the management of system alarms.
class NUAlarm(NURESTObject):
""" Represents a Alarm in the VSD
Notes:
The alarm API allows the management of system alarms.
"""
__rest_name__ = "alarm"
__resource_name__ = "alarms"
## Constants
CONST_SEVERITY_WARNING = "WARNING"
CONST_SEVERITY_MAJOR = "MAJOR"
CONST_SEVERITY_CRITICAL = "CRITICAL"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_SEVERITY_INFO = "INFO"
CONST_SEVERITY_MINOR = "MINOR"
def __init__(self, **kwargs):
""" Initializes a Alarm instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> alarm = NUAlarm(id=u'xxxx-xxx-xxx-xxx', name=u'Alarm')
>>> alarm = NUAlarm(data=my_dict)
"""
super(NUAlarm, self).__init__()
# Read/Write Attributes
self._name = None
self._target_object = None
self._last_updated_by = None
self._acknowledged = None
self._reason = None
self._description = None
self._severity = None
self._timestamp = None
self._enterprise_id = None
self._entity_scope = None
self._error_condition = None
self._number_of_occurances = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="target_object", remote_name="targetObject", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="acknowledged", remote_name="acknowledged", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="reason", remote_name="reason", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="severity", remote_name="severity", attribute_type=str, is_required=False, is_unique=False, choices=[u'CRITICAL', u'INFO', u'MAJOR', u'MINOR', u'WARNING'])
self.expose_attribute(local_name="timestamp", remote_name="timestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="error_condition", remote_name="errorCondition", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_occurances", remote_name="numberOfOccurances", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The alarm name. Each type of alarm will generate its own name
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The alarm name. Each type of alarm will generate its own name
"""
self._name = value
@property
def target_object(self):
""" Get target_object value.
Notes:
Identifies affected Entity. Example: Alarm generated by TCA for Domain domain1(Packets towards a VM, Breach)
This attribute is named `targetObject` in VSD API.
"""
return self._target_object
@target_object.setter
def target_object(self, value):
""" Set target_object value.
Notes:
Identifies affected Entity. Example: Alarm generated by TCA for Domain domain1(Packets towards a VM, Breach)
This attribute is named `targetObject` in VSD API.
"""
self._target_object = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def acknowledged(self):
""" Get acknowledged value.
Notes:
Flag to indicate that alarm is already acknowledged or not
"""
return self._acknowledged
@acknowledged.setter
def acknowledged(self, value):
""" Set acknowledged value.
Notes:
Flag to indicate that alarm is already acknowledged or not
"""
self._acknowledged = value
@property
def reason(self):
""" Get reason value.
Notes:
Provides a description of the alarm
"""
return self._reason
@reason.setter
def reason(self, value):
""" Set reason value.
Notes:
Provides a description of the alarm
"""
self._reason = value
@property
def description(self):
""" Get description value.
Notes:
Description of the alarm
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the alarm
"""
self._description = value
@property
def severity(self):
""" Get severity value.
Notes:
Severity of the alarm.
"""
return self._severity
@severity.setter
def severity(self, value):
""" Set severity value.
Notes:
Severity of the alarm.
"""
self._severity = value
@property
def timestamp(self):
""" Get timestamp value.
Notes:
Indicates the time that the alarm was triggered
"""
return self._timestamp
@timestamp.setter
def timestamp(self, value):
""" Set timestamp value.
Notes:
Indicates the time that the alarm was triggered
"""
self._timestamp = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
Enterprise that this alarm belongs to
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
Enterprise that this alarm belongs to
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def error_condition(self):
""" Get error_condition value.
Notes:
Identifies the error condition
This attribute is named `errorCondition` in VSD API.
"""
return self._error_condition
@error_condition.setter
def error_condition(self, value):
""" Set error_condition value.
Notes:
Identifies the error condition
This attribute is named `errorCondition` in VSD API.
"""
self._error_condition = value
@property
def number_of_occurances(self):
""" Get number_of_occurances value.
Notes:
Number of times that the alarm was triggered
This attribute is named `numberOfOccurances` in VSD API.
"""
return self._number_of_occurances
@number_of_occurances.setter
def number_of_occurances(self, value):
""" Set number_of_occurances value.
Notes:
Number of times that the alarm was triggered
This attribute is named `numberOfOccurances` in VSD API.
"""
self._number_of_occurances = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUAlarm
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SEVERITY_CRITICAL
var CONST_SEVERITY_INFO
var CONST_SEVERITY_MAJOR
var CONST_SEVERITY_MINOR
var CONST_SEVERITY_WARNING
var resource_name
var rest_name
Instance variables
var acknowledged
Get acknowledged value.
Notes: Flag to indicate that alarm is already acknowledged or not
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the alarm
var enterprise_id
Get enterprise_id value.
Notes: Enterprise that this alarm belongs to
This attribute is named `enterpriseID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var error_condition
Get error_condition value.
Notes: Identifies the error condition
This attribute is named `errorCondition` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: The alarm name. Each type of alarm will generate its own name
var number_of_occurances
Get number_of_occurances value.
Notes: Number of times that the alarm was triggered
This attribute is named `numberOfOccurances` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var reason
Get reason value.
Notes: Provides a description of the alarm
var severity
Get severity value.
Notes: Severity of the alarm.
var target_object
Get target_object value.
Notes: Identifies affected Entity. Example: Alarm generated by TCA for Domain domain1(Packets towards a VM, Breach)
This attribute is named `targetObject` in VSD API.
var timestamp
Get timestamp value.
Notes: Indicates the time that the alarm was triggered
Methods
def __init__(
self, **kwargs)
Initializes a Alarm instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> alarm = NUAlarm(id=u'xxxx-xxx-xxx-xxx', name=u'Alarm') >>> alarm = NUAlarm(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Alarm instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> alarm = NUAlarm(id=u'xxxx-xxx-xxx-xxx', name=u'Alarm')
>>> alarm = NUAlarm(data=my_dict)
"""
super(NUAlarm, self).__init__()
# Read/Write Attributes
self._name = None
self._target_object = None
self._last_updated_by = None
self._acknowledged = None
self._reason = None
self._description = None
self._severity = None
self._timestamp = None
self._enterprise_id = None
self._entity_scope = None
self._error_condition = None
self._number_of_occurances = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="target_object", remote_name="targetObject", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="acknowledged", remote_name="acknowledged", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="reason", remote_name="reason", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="severity", remote_name="severity", attribute_type=str, is_required=False, is_unique=False, choices=[u'CRITICAL', u'INFO', u'MAJOR', u'MINOR', u'WARNING'])
self.expose_attribute(local_name="timestamp", remote_name="timestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="error_condition", remote_name="errorCondition", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_occurances", remote_name="numberOfOccurances", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUApp
Represents a App in the VSD
Notes: Represents a real life application like a vendor website, or a social network.
class NUApp(NURESTObject):
""" Represents a App in the VSD
Notes:
Represents a real life application like a vendor website, or a social network.
"""
__rest_name__ = "application"
__resource_name__ = "applications"
## Constants
CONST_ASSOCIATED_DOMAIN_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_DOMAIN_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a App instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> app = NUApp(id=u'xxxx-xxx-xxx-xxx', name=u'App')
>>> app = NUApp(data=my_dict)
"""
super(NUApp, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._assoc_egress_acl_template_id = None
self._assoc_ingress_acl_template_id = None
self._associated_domain_id = None
self._associated_domain_type = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="assoc_egress_acl_template_id", remote_name="assocEgressACLTemplateId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_ingress_acl_template_id", remote_name="assocIngressACLTemplateId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_domain_id", remote_name="associatedDomainID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_domain_type", remote_name="associatedDomainType", attribute_type=str, is_required=True, is_unique=False, choices=[u'DOMAIN', u'L2DOMAIN'])
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOMAIN', u'ENTERPRISE', u'ZONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.tiers = NUTiersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.flows = NUFlowsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the application.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the application.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the application.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the application.
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def assoc_egress_acl_template_id(self):
""" Get assoc_egress_acl_template_id value.
Notes:
The ID of the ACL template that this application is pointing to.
This attribute is named `assocEgressACLTemplateId` in VSD API.
"""
return self._assoc_egress_acl_template_id
@assoc_egress_acl_template_id.setter
def assoc_egress_acl_template_id(self, value):
""" Set assoc_egress_acl_template_id value.
Notes:
The ID of the ACL template that this application is pointing to.
This attribute is named `assocEgressACLTemplateId` in VSD API.
"""
self._assoc_egress_acl_template_id = value
@property
def assoc_ingress_acl_template_id(self):
""" Get assoc_ingress_acl_template_id value.
Notes:
The ID of the ACL template that this application is pointing to
This attribute is named `assocIngressACLTemplateId` in VSD API.
"""
return self._assoc_ingress_acl_template_id
@assoc_ingress_acl_template_id.setter
def assoc_ingress_acl_template_id(self, value):
""" Set assoc_ingress_acl_template_id value.
Notes:
The ID of the ACL template that this application is pointing to
This attribute is named `assocIngressACLTemplateId` in VSD API.
"""
self._assoc_ingress_acl_template_id = value
@property
def associated_domain_id(self):
""" Get associated_domain_id value.
Notes:
Domain id where the application is running.
This attribute is named `associatedDomainID` in VSD API.
"""
return self._associated_domain_id
@associated_domain_id.setter
def associated_domain_id(self, value):
""" Set associated_domain_id value.
Notes:
Domain id where the application is running.
This attribute is named `associatedDomainID` in VSD API.
"""
self._associated_domain_id = value
@property
def associated_domain_type(self):
""" Get associated_domain_type value.
Notes:
Type of domain (DOMAIN, L2DOMAIN). Refer to API section for supported types.
This attribute is named `associatedDomainType` in VSD API.
"""
return self._associated_domain_type
@associated_domain_type.setter
def associated_domain_type(self, value):
""" Set associated_domain_type value.
Notes:
Type of domain (DOMAIN, L2DOMAIN). Refer to API section for supported types.
This attribute is named `associatedDomainType` in VSD API.
"""
self._associated_domain_type = value
@property
def associated_network_object_id(self):
""" Get associated_network_object_id value.
Notes:
ID of the network object that this App is associated with.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
return self._associated_network_object_id
@associated_network_object_id.setter
def associated_network_object_id(self, value):
""" Set associated_network_object_id value.
Notes:
ID of the network object that this App is associated with.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
self._associated_network_object_id = value
@property
def associated_network_object_type(self):
""" Get associated_network_object_type value.
Notes:
Type of network object this App is associated with (ENTERPRISE, DOMAIN) Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
return self._associated_network_object_type
@associated_network_object_type.setter
def associated_network_object_type(self, value):
""" Set associated_network_object_type value.
Notes:
Type of network object this App is associated with (ENTERPRISE, DOMAIN) Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
self._associated_network_object_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUApp
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ASSOCIATED_DOMAIN_TYPE_DOMAIN
var CONST_ASSOCIATED_DOMAIN_TYPE_L2DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var assoc_egress_acl_template_id
Get assoc_egress_acl_template_id value.
Notes: The ID of the ACL template that this application is pointing to.
This attribute is named `assocEgressACLTemplateId` in VSD API.
var assoc_ingress_acl_template_id
Get assoc_ingress_acl_template_id value.
Notes: The ID of the ACL template that this application is pointing to
This attribute is named `assocIngressACLTemplateId` in VSD API.
var associated_domain_id
Get associated_domain_id value.
Notes: Domain id where the application is running.
This attribute is named `associatedDomainID` in VSD API.
var associated_domain_type
Get associated_domain_type value.
Notes: Type of domain (DOMAIN, L2DOMAIN). Refer to API section for supported types.
This attribute is named `associatedDomainType` in VSD API.
var associated_network_object_id
Get associated_network_object_id value.
Notes: ID of the network object that this App is associated with.
This attribute is named `associatedNetworkObjectID` in VSD API.
var associated_network_object_type
Get associated_network_object_type value.
Notes: Type of network object this App is associated with (ENTERPRISE, DOMAIN) Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the application.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flows
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the application.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var tiers
Methods
def __init__(
self, **kwargs)
Initializes a App instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> app = NUApp(id=u'xxxx-xxx-xxx-xxx', name=u'App') >>> app = NUApp(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a App instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> app = NUApp(id=u'xxxx-xxx-xxx-xxx', name=u'App')
>>> app = NUApp(data=my_dict)
"""
super(NUApp, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._assoc_egress_acl_template_id = None
self._assoc_ingress_acl_template_id = None
self._associated_domain_id = None
self._associated_domain_type = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="assoc_egress_acl_template_id", remote_name="assocEgressACLTemplateId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_ingress_acl_template_id", remote_name="assocIngressACLTemplateId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_domain_id", remote_name="associatedDomainID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_domain_type", remote_name="associatedDomainType", attribute_type=str, is_required=True, is_unique=False, choices=[u'DOMAIN', u'L2DOMAIN'])
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOMAIN', u'ENTERPRISE', u'ZONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.tiers = NUTiersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.flows = NUFlowsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUApplicationService
Represents a ApplicationService in the VSD
Notes: Represents a networking communication service.
class NUApplicationService(NURESTObject):
""" Represents a ApplicationService in the VSD
Notes:
Represents a networking communication service.
"""
__rest_name__ = "applicationservice"
__resource_name__ = "applicationservices"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_DIRECTION_UNIDIRECTIONAL = "UNIDIRECTIONAL"
CONST_DIRECTION_REFLEXIVE = "REFLEXIVE"
def __init__(self, **kwargs):
""" Initializes a ApplicationService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> applicationservice = NUApplicationService(id=u'xxxx-xxx-xxx-xxx', name=u'ApplicationService')
>>> applicationservice = NUApplicationService(data=my_dict)
"""
super(NUApplicationService, self).__init__()
# Read/Write Attributes
self._dscp = None
self._name = None
self._last_updated_by = None
self._description = None
self._destination_port = None
self._direction = None
self._entity_scope = None
self._source_port = None
self._protocol = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="direction", remote_name="direction", attribute_type=str, is_required=True, is_unique=False, choices=[u'REFLEXIVE', u'UNIDIRECTIONAL'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63. Required for etherType 0x0800
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63. Required for etherType 0x0800
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def name(self):
""" Get name value.
Notes:
Name of the application service.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the application service.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the application service.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the application service.
"""
self._description = value
@property
def destination_port(self):
""" Get destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range.
This attribute is named `destinationPort` in VSD API.
"""
return self._destination_port
@destination_port.setter
def destination_port(self, value):
""" Set destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range.
This attribute is named `destinationPort` in VSD API.
"""
self._destination_port = value
@property
def direction(self):
""" Get direction value.
Notes:
Direction of the service. Default is UNIDIRECTIONAL.
"""
return self._direction
@direction.setter
def direction(self, value):
""" Set direction value.
Notes:
Direction of the service. Default is UNIDIRECTIONAL.
"""
self._direction = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def source_port(self):
""" Get source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range.
This attribute is named `sourcePort` in VSD API.
"""
return self._source_port
@source_port.setter
def source_port(self, value):
""" Set source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range.
This attribute is named `sourcePort` in VSD API.
"""
self._source_port = value
@property
def protocol(self):
""" Get protocol value.
Notes:
Protocol that must be matched. Needs to be 6 (TCP) or 17 (UDP)
"""
return self._protocol
@protocol.setter
def protocol(self, value):
""" Set protocol value.
Notes:
Protocol that must be matched. Needs to be 6 (TCP) or 17 (UDP)
"""
self._protocol = value
@property
def ether_type(self):
""" Get ether_type value.
Notes:
Ether type of the packet to be matched. Ether type can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
return self._ether_type
@ether_type.setter
def ether_type(self, value):
""" Set ether_type value.
Notes:
Ether type of the packet to be matched. Ether type can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
self._ether_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUApplicationService
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_DIRECTION_REFLEXIVE
var CONST_DIRECTION_UNIDIRECTIONAL
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the application service.
var destination_port
Get destination_port value.
Notes: The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range.
This attribute is named `destinationPort` in VSD API.
var direction
Get direction value.
Notes: Direction of the service. Default is UNIDIRECTIONAL.
var dscp
Get dscp value.
Notes: DSCP match condition to be set in the rule. It is either * or from 0-63. Required for etherType 0x0800
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var ether_type
Get ether_type value.
Notes: Ether type of the packet to be matched. Ether type can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the application service.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var protocol
Get protocol value.
Notes: Protocol that must be matched. Needs to be 6 (TCP) or 17 (UDP)
var source_port
Get source_port value.
Notes: Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range.
This attribute is named `sourcePort` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a ApplicationService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> applicationservice = NUApplicationService(id=u'xxxx-xxx-xxx-xxx', name=u'ApplicationService') >>> applicationservice = NUApplicationService(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a ApplicationService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> applicationservice = NUApplicationService(id=u'xxxx-xxx-xxx-xxx', name=u'ApplicationService')
>>> applicationservice = NUApplicationService(data=my_dict)
"""
super(NUApplicationService, self).__init__()
# Read/Write Attributes
self._dscp = None
self._name = None
self._last_updated_by = None
self._description = None
self._destination_port = None
self._direction = None
self._entity_scope = None
self._source_port = None
self._protocol = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="direction", remote_name="direction", attribute_type=str, is_required=True, is_unique=False, choices=[u'REFLEXIVE', u'UNIDIRECTIONAL'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUAutoDiscoveredGateway
Represents a AutoDiscoveredGateway in the VSD
Notes: Represents Auto discovered Gateway.
class NUAutoDiscoveredGateway(NURESTObject):
""" Represents a AutoDiscoveredGateway in the VSD
Notes:
Represents Auto discovered Gateway.
"""
__rest_name__ = "autodiscoveredgateway"
__resource_name__ = "autodiscoveredgateways"
## Constants
CONST_PERSONALITY_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_PERSONALITY_VSA = "VSA"
CONST_PERSONALITY_VSG = "VSG"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PERSONALITY_OTHER = "OTHER"
CONST_PERSONALITY_NSG = "NSG"
CONST_PERSONALITY_VRSG = "VRSG"
CONST_PERSONALITY_DC7X50 = "DC7X50"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a AutoDiscoveredGateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> autodiscoveredgateway = NUAutoDiscoveredGateway(id=u'xxxx-xxx-xxx-xxx', name=u'AutoDiscoveredGateway')
>>> autodiscoveredgateway = NUAutoDiscoveredGateway(data=my_dict)
"""
super(NUAutoDiscoveredGateway, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway_id = None
self._peer = None
self._personality = None
self._description = None
self._entity_scope = None
self._controllers = None
self._vtep = None
self._external_id = None
self._system_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer", remote_name="peer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=True, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="controllers", remote_name="controllers", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="vtep", remote_name="vtep", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_id", remote_name="systemID", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.wan_services = NUWANServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ports = NUPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_ports = NUNSPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Gateway
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Gateway
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_id(self):
""" Get gateway_id value.
Notes:
The Gateway associated with this Auto Discovered Gateway . This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
return self._gateway_id
@gateway_id.setter
def gateway_id(self, value):
""" Set gateway_id value.
Notes:
The Gateway associated with this Auto Discovered Gateway . This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
self._gateway_id = value
@property
def peer(self):
""" Get peer value.
Notes:
The System ID of the peer gateway associated with this Gateway instance when it is discovered by the network manager (VSD) as being redundant.
"""
return self._peer
@peer.setter
def peer(self, value):
""" Set peer value.
Notes:
The System ID of the peer gateway associated with this Gateway instance when it is discovered by the network manager (VSD) as being redundant.
"""
self._peer = value
@property
def personality(self):
""" Get personality value.
Notes:
Personality of the Gateway - VSG,VRSG,NONE,OTHER, cannot be changed after creation.
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
Personality of the Gateway - VSG,VRSG,NONE,OTHER, cannot be changed after creation.
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Gateway
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Gateway
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def controllers(self):
""" Get controllers value.
Notes:
Controllers to which this gateway instance is associated with.
"""
return self._controllers
@controllers.setter
def controllers(self, value):
""" Set controllers value.
Notes:
Controllers to which this gateway instance is associated with.
"""
self._controllers = value
@property
def vtep(self):
""" Get vtep value.
Notes:
Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
"""
return self._vtep
@vtep.setter
def vtep(self, value):
""" Set vtep value.
Notes:
Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
"""
self._vtep = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def system_id(self):
""" Get system_id value.
Notes:
Identifier of the Gateway
This attribute is named `systemID` in VSD API.
"""
return self._system_id
@system_id.setter
def system_id(self, value):
""" Set system_id value.
Notes:
Identifier of the Gateway
This attribute is named `systemID` in VSD API.
"""
self._system_id = value
Ancestors (in MRO)
- NUAutoDiscoveredGateway
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERSONALITY_DC7X50
var CONST_PERSONALITY_HARDWARE_VTEP
var CONST_PERSONALITY_NSG
var CONST_PERSONALITY_OTHER
var CONST_PERSONALITY_VRSG
var CONST_PERSONALITY_VSA
var CONST_PERSONALITY_VSG
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var controllers
Get controllers value.
Notes: Controllers to which this gateway instance is associated with.
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Gateway
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_id
Get gateway_id value.
Notes: The Gateway associated with this Auto Discovered Gateway . This is a read only attribute
This attribute is named `gatewayID` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Gateway
var ns_ports
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var peer
Get peer value.
Notes: The System ID of the peer gateway associated with this Gateway instance when it is discovered by the network manager (VSD) as being redundant.
var personality
Get personality value.
Notes: Personality of the Gateway - VSG,VRSG,NONE,OTHER, cannot be changed after creation.
var ports
var system_id
Get system_id value.
Notes: Identifier of the Gateway
This attribute is named `systemID` in VSD API.
var vtep
Get vtep value.
Notes: Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
var wan_services
Methods
def __init__(
self, **kwargs)
Initializes a AutoDiscoveredGateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> autodiscoveredgateway = NUAutoDiscoveredGateway(id=u'xxxx-xxx-xxx-xxx', name=u'AutoDiscoveredGateway') >>> autodiscoveredgateway = NUAutoDiscoveredGateway(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a AutoDiscoveredGateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> autodiscoveredgateway = NUAutoDiscoveredGateway(id=u'xxxx-xxx-xxx-xxx', name=u'AutoDiscoveredGateway')
>>> autodiscoveredgateway = NUAutoDiscoveredGateway(data=my_dict)
"""
super(NUAutoDiscoveredGateway, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway_id = None
self._peer = None
self._personality = None
self._description = None
self._entity_scope = None
self._controllers = None
self._vtep = None
self._external_id = None
self._system_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer", remote_name="peer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=True, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="controllers", remote_name="controllers", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="vtep", remote_name="vtep", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_id", remote_name="systemID", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.wan_services = NUWANServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ports = NUPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_ports = NUNSPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUBGPPeer
Represents a BGPPeer in the VSD
Notes: Encapsulates the BGP peer information for system monitor entity.
class NUBGPPeer(NURESTObject):
""" Represents a BGPPeer in the VSD
Notes:
Encapsulates the BGP peer information for system monitor entity.
"""
__rest_name__ = "bgppeer"
__resource_name__ = "bgppeers"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_STATUS_DOWN = "DOWN"
CONST_STATUS_UP = "UP"
CONST_STATUS_ADMIN_DOWN = "ADMIN_DOWN"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a BGPPeer instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bgppeer = NUBGPPeer(id=u'xxxx-xxx-xxx-xxx', name=u'BGPPeer')
>>> bgppeer = NUBGPPeer(data=my_dict)
"""
super(NUBGPPeer, self).__init__()
# Read/Write Attributes
self._last_state_change = None
self._address = None
self._entity_scope = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_state_change(self):
""" Get last_state_change value.
Notes:
Last state change timestamp.
This attribute is named `lastStateChange` in VSD API.
"""
return self._last_state_change
@last_state_change.setter
def last_state_change(self, value):
""" Set last_state_change value.
Notes:
Last state change timestamp.
This attribute is named `lastStateChange` in VSD API.
"""
self._last_state_change = value
@property
def address(self):
""" Get address value.
Notes:
IP of the BGP peer.
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP of the BGP peer.
"""
self._address = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def status(self):
""" Get status value.
Notes:
Current connection status of the BGP peer.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Current connection status of the BGP peer.
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUBGPPeer
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_STATUS_ADMIN_DOWN
var CONST_STATUS_DOWN
var CONST_STATUS_UP
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP of the BGP peer.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_state_change
Get last_state_change value.
Notes: Last state change timestamp.
This attribute is named `lastStateChange` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var status
Get status value.
Notes: Current connection status of the BGP peer.
Methods
def __init__(
self, **kwargs)
Initializes a BGPPeer instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> bgppeer = NUBGPPeer(id=u'xxxx-xxx-xxx-xxx', name=u'BGPPeer') >>> bgppeer = NUBGPPeer(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a BGPPeer instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bgppeer = NUBGPPeer(id=u'xxxx-xxx-xxx-xxx', name=u'BGPPeer')
>>> bgppeer = NUBGPPeer(data=my_dict)
"""
super(NUBGPPeer, self).__init__()
# Read/Write Attributes
self._last_state_change = None
self._address = None
self._entity_scope = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUBootstrap
Represents a Bootstrap in the VSD
Notes: Gateway bootstrap details.
class NUBootstrap(NURESTObject):
""" Represents a Bootstrap in the VSD
Notes:
Gateway bootstrap details.
"""
__rest_name__ = "bootstrap"
__resource_name__ = "bootstraps"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_STATUS_NOTIFICATION_APP_REQ_SENT = "NOTIFICATION_APP_REQ_SENT"
CONST_STATUS_INACTIVE = "INACTIVE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_STATUS_NOTIFICATION_APP_REQ_ACK = "NOTIFICATION_APP_REQ_ACK"
CONST_STATUS_ACTIVE = "ACTIVE"
CONST_STATUS_CERTIFICATE_SIGNED = "CERTIFICATE_SIGNED"
def __init__(self, **kwargs):
""" Initializes a Bootstrap instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bootstrap = NUBootstrap(id=u'xxxx-xxx-xxx-xxx', name=u'Bootstrap')
>>> bootstrap = NUBootstrap(data=my_dict)
"""
super(NUBootstrap, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._installer_id = None
self._entity_scope = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="installer_id", remote_name="installerID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACTIVE', u'CERTIFICATE_SIGNED', u'INACTIVE', u'NOTIFICATION_APP_REQ_ACK', u'NOTIFICATION_APP_REQ_SENT'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def installer_id(self):
""" Get installer_id value.
Notes:
The Installer ID
This attribute is named `installerID` in VSD API.
"""
return self._installer_id
@installer_id.setter
def installer_id(self, value):
""" Set installer_id value.
Notes:
The Installer ID
This attribute is named `installerID` in VSD API.
"""
self._installer_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def status(self):
""" Get status value.
Notes:
Bootstrap status.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Bootstrap status.
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUBootstrap
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_STATUS_ACTIVE
var CONST_STATUS_CERTIFICATE_SIGNED
var CONST_STATUS_INACTIVE
var CONST_STATUS_NOTIFICATION_APP_REQ_ACK
var CONST_STATUS_NOTIFICATION_APP_REQ_SENT
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var installer_id
Get installer_id value.
Notes: The Installer ID
This attribute is named `installerID` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var status
Get status value.
Notes: Bootstrap status.
Methods
def __init__(
self, **kwargs)
Initializes a Bootstrap instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> bootstrap = NUBootstrap(id=u'xxxx-xxx-xxx-xxx', name=u'Bootstrap') >>> bootstrap = NUBootstrap(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Bootstrap instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bootstrap = NUBootstrap(id=u'xxxx-xxx-xxx-xxx', name=u'Bootstrap')
>>> bootstrap = NUBootstrap(data=my_dict)
"""
super(NUBootstrap, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._installer_id = None
self._entity_scope = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="installer_id", remote_name="installerID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACTIVE', u'CERTIFICATE_SIGNED', u'INACTIVE', u'NOTIFICATION_APP_REQ_ACK', u'NOTIFICATION_APP_REQ_SENT'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUBootstrapActivation
Represents a BootstrapActivation in the VSD
Notes: NSG Gateway initiated Bootstrap Activation
class NUBootstrapActivation(NURESTObject):
""" Represents a BootstrapActivation in the VSD
Notes:
NSG Gateway initiated Bootstrap Activation
"""
__rest_name__ = "bootstrapactivation"
__resource_name__ = "bootstrapactivations"
## Constants
CONST_ACTION_ROLLBACK = "ROLLBACK"
CONST_ACTION_INITIATE = "INITIATE"
CONST_ACTION_NO_AUTH_REQUIRED = "NO_AUTH_REQUIRED"
CONST_ACTION_AUTHENTICATE = "AUTHENTICATE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ACTION_NEW_NCPE_AUTH_REQUIRED = "NEW_NCPE_AUTH_REQUIRED"
CONST_ACTION_UNSPECIFIED = "UNSPECIFIED"
CONST_ACTION_INITIATE_RENEW = "INITIATE_RENEW"
CONST_ACTION_CERTIFICATE_SIGNED = "CERTIFICATE_SIGNED"
CONST_ACTION_ROLLED_BACK = "ROLLED_BACK"
CONST_ACTION_CERTIFICATE_REVOKE = "CERTIFICATE_REVOKE"
CONST_ACTION_BOOTSTRAP_COMPLETE = "BOOTSTRAP_COMPLETE"
CONST_ACTION_CONFIRM = "CONFIRM"
CONST_ACTION_CERTIFICATE_RENEW = "CERTIFICATE_RENEW"
def __init__(self, **kwargs):
""" Initializes a BootstrapActivation instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bootstrapactivation = NUBootstrapActivation(id=u'xxxx-xxx-xxx-xxx', name=u'BootstrapActivation')
>>> bootstrapactivation = NUBootstrapActivation(data=my_dict)
"""
super(NUBootstrapActivation, self).__init__()
# Read/Write Attributes
self._cacert = None
self._hash = None
self._last_updated_by = None
self._action = None
self._seed = None
self._cert = None
self._entity_scope = None
self._config_url = None
self._tpm_owner_password = None
self._srk_password = None
self._vsd_time = None
self._csr = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="cacert", remote_name="cacert", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="hash", remote_name="hash", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'AUTHENTICATE', u'BOOTSTRAP_COMPLETE', u'CERTIFICATE_RENEW', u'CERTIFICATE_REVOKE', u'CERTIFICATE_SIGNED', u'CONFIRM', u'INITIATE', u'INITIATE_RENEW', u'NEW_NCPE_AUTH_REQUIRED', u'NO_AUTH_REQUIRED', u'ROLLBACK', u'ROLLED_BACK', u'UNSPECIFIED'])
self.expose_attribute(local_name="seed", remote_name="seed", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="cert", remote_name="cert", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="config_url", remote_name="configURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tpm_owner_password", remote_name="tpmOwnerPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="srk_password", remote_name="srkPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsd_time", remote_name="vsdTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="csr", remote_name="csr", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def cacert(self):
""" Get cacert value.
Notes:
The CA Certificate Chain
"""
return self._cacert
@cacert.setter
def cacert(self, value):
""" Set cacert value.
Notes:
The CA Certificate Chain
"""
self._cacert = value
@property
def hash(self):
""" Get hash value.
Notes:
The authentication hash of this request
"""
return self._hash
@hash.setter
def hash(self, value):
""" Set hash value.
Notes:
The authentication hash of this request
"""
self._hash = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def action(self):
""" Get action value.
Notes:
The bootstrap action to perform.
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The bootstrap action to perform.
"""
self._action = value
@property
def seed(self):
""" Get seed value.
Notes:
The random seed for this request
"""
return self._seed
@seed.setter
def seed(self, value):
""" Set seed value.
Notes:
The random seed for this request
"""
self._seed = value
@property
def cert(self):
""" Get cert value.
Notes:
The signed Certificate
"""
return self._cert
@cert.setter
def cert(self, value):
""" Set cert value.
Notes:
The signed Certificate
"""
self._cert = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def config_url(self):
""" Get config_url value.
Notes:
The configuration URL
This attribute is named `configURL` in VSD API.
"""
return self._config_url
@config_url.setter
def config_url(self, value):
""" Set config_url value.
Notes:
The configuration URL
This attribute is named `configURL` in VSD API.
"""
self._config_url = value
@property
def tpm_owner_password(self):
""" Get tpm_owner_password value.
Notes:
TPM owner passphrase
This attribute is named `tpmOwnerPassword` in VSD API.
"""
return self._tpm_owner_password
@tpm_owner_password.setter
def tpm_owner_password(self, value):
""" Set tpm_owner_password value.
Notes:
TPM owner passphrase
This attribute is named `tpmOwnerPassword` in VSD API.
"""
self._tpm_owner_password = value
@property
def srk_password(self):
""" Get srk_password value.
Notes:
TPM SRK passphrase
This attribute is named `srkPassword` in VSD API.
"""
return self._srk_password
@srk_password.setter
def srk_password(self, value):
""" Set srk_password value.
Notes:
TPM SRK passphrase
This attribute is named `srkPassword` in VSD API.
"""
self._srk_password = value
@property
def vsd_time(self):
""" Get vsd_time value.
Notes:
VSD Server time when an NSG is initiating a Bootstrapping request
This attribute is named `vsdTime` in VSD API.
"""
return self._vsd_time
@vsd_time.setter
def vsd_time(self, value):
""" Set vsd_time value.
Notes:
VSD Server time when an NSG is initiating a Bootstrapping request
This attribute is named `vsdTime` in VSD API.
"""
self._vsd_time = value
@property
def csr(self):
""" Get csr value.
Notes:
The CSR of the request
"""
return self._csr
@csr.setter
def csr(self, value):
""" Set csr value.
Notes:
The CSR of the request
"""
self._csr = value
@property
def status(self):
""" Get status value.
Notes:
The agent status for the request
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
The agent status for the request
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUBootstrapActivation
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_AUTHENTICATE
var CONST_ACTION_BOOTSTRAP_COMPLETE
var CONST_ACTION_CERTIFICATE_RENEW
var CONST_ACTION_CERTIFICATE_REVOKE
var CONST_ACTION_CERTIFICATE_SIGNED
var CONST_ACTION_CONFIRM
var CONST_ACTION_INITIATE
var CONST_ACTION_INITIATE_RENEW
var CONST_ACTION_NEW_NCPE_AUTH_REQUIRED
var CONST_ACTION_NO_AUTH_REQUIRED
var CONST_ACTION_ROLLBACK
var CONST_ACTION_ROLLED_BACK
var CONST_ACTION_UNSPECIFIED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The bootstrap action to perform.
var cacert
Get cacert value.
Notes: The CA Certificate Chain
var cert
Get cert value.
Notes: The signed Certificate
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var config_url
Get config_url value.
Notes: The configuration URL
This attribute is named `configURL` in VSD API.
var creation_date
Get creation date
var csr
Get csr value.
Notes: The CSR of the request
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var hash
Get hash value.
Notes: The authentication hash of this request
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var seed
Get seed value.
Notes: The random seed for this request
var srk_password
Get srk_password value.
Notes: TPM SRK passphrase
This attribute is named `srkPassword` in VSD API.
var status
Get status value.
Notes: The agent status for the request
var tpm_owner_password
Get tpm_owner_password value.
Notes: TPM owner passphrase
This attribute is named `tpmOwnerPassword` in VSD API.
var vsd_time
Get vsd_time value.
Notes: VSD Server time when an NSG is initiating a Bootstrapping request
This attribute is named `vsdTime` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a BootstrapActivation instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> bootstrapactivation = NUBootstrapActivation(id=u'xxxx-xxx-xxx-xxx', name=u'BootstrapActivation') >>> bootstrapactivation = NUBootstrapActivation(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a BootstrapActivation instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bootstrapactivation = NUBootstrapActivation(id=u'xxxx-xxx-xxx-xxx', name=u'BootstrapActivation')
>>> bootstrapactivation = NUBootstrapActivation(data=my_dict)
"""
super(NUBootstrapActivation, self).__init__()
# Read/Write Attributes
self._cacert = None
self._hash = None
self._last_updated_by = None
self._action = None
self._seed = None
self._cert = None
self._entity_scope = None
self._config_url = None
self._tpm_owner_password = None
self._srk_password = None
self._vsd_time = None
self._csr = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="cacert", remote_name="cacert", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="hash", remote_name="hash", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'AUTHENTICATE', u'BOOTSTRAP_COMPLETE', u'CERTIFICATE_RENEW', u'CERTIFICATE_REVOKE', u'CERTIFICATE_SIGNED', u'CONFIRM', u'INITIATE', u'INITIATE_RENEW', u'NEW_NCPE_AUTH_REQUIRED', u'NO_AUTH_REQUIRED', u'ROLLBACK', u'ROLLED_BACK', u'UNSPECIFIED'])
self.expose_attribute(local_name="seed", remote_name="seed", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="cert", remote_name="cert", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="config_url", remote_name="configURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tpm_owner_password", remote_name="tpmOwnerPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="srk_password", remote_name="srkPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsd_time", remote_name="vsdTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="csr", remote_name="csr", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUBridgeInterface
Represents a BridgeInterface in the VSD
Notes: Provides information for each bridge interface.
class NUBridgeInterface(NURESTObject):
""" Represents a BridgeInterface in the VSD
Notes:
Provides information for each bridge interface.
"""
__rest_name__ = "bridgeinterface"
__resource_name__ = "bridgeinterfaces"
## Constants
CONST_ATTACHED_NETWORK_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ATTACHED_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a BridgeInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bridgeinterface = NUBridgeInterface(id=u'xxxx-xxx-xxx-xxx', name=u'BridgeInterface')
>>> bridgeinterface = NUBridgeInterface(data=my_dict)
"""
super(NUBridgeInterface, self).__init__()
# Read/Write Attributes
self._vport_id = None
self._vport_name = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._netmask = None
self._network_name = None
self._tier_id = None
self._entity_scope = None
self._policy_decision_id = None
self._domain_id = None
self._domain_name = None
self._zone_id = None
self._zone_name = None
self._associated_floating_ip_address = None
self._attached_network_id = None
self._attached_network_type = None
self._external_id = None
self.expose_attribute(local_name="vport_id", remote_name="VPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tier_id", remote_name="tierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_decision_id", remote_name="policyDecisionID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_name", remote_name="zoneName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_address", remote_name="associatedFloatingIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_id", remote_name="attachedNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'L2DOMAIN', u'SUBNET'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_decisions = NUPolicyDecisionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vport_id(self):
""" Get vport_id value.
Notes:
ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
"""
return self._vport_id
@vport_id.setter
def vport_id(self, value):
""" Set vport_id value.
Notes:
ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
"""
self._vport_id = value
@property
def vport_name(self):
""" Get vport_name value.
Notes:
Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
"""
return self._vport_name
@vport_name.setter
def vport_name(self, value):
""" Set vport_name value.
Notes:
Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
"""
self._vport_name = value
@property
def name(self):
""" Get name value.
Notes:
Device name associated with this interface
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Device name associated with this interface
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
Gateway of the subnet that the VM is connected to
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
Gateway of the subnet that the VM is connected to
"""
self._gateway = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet that the VM is attached to
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet that the VM is attached to
"""
self._netmask = value
@property
def network_name(self):
""" Get network_name value.
Notes:
Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
"""
return self._network_name
@network_name.setter
def network_name(self, value):
""" Set network_name value.
Notes:
Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
"""
self._network_name = value
@property
def tier_id(self):
""" Get tier_id value.
Notes:
ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
"""
return self._tier_id
@tier_id.setter
def tier_id(self, value):
""" Set tier_id value.
Notes:
ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
"""
self._tier_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_decision_id(self):
""" Get policy_decision_id value.
Notes:
The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
"""
return self._policy_decision_id
@policy_decision_id.setter
def policy_decision_id(self, value):
""" Set policy_decision_id value.
Notes:
The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
"""
self._policy_decision_id = value
@property
def domain_id(self):
""" Get domain_id value.
Notes:
ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
"""
return self._domain_id
@domain_id.setter
def domain_id(self, value):
""" Set domain_id value.
Notes:
ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
"""
self._domain_id = value
@property
def domain_name(self):
""" Get domain_name value.
Notes:
Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
"""
return self._domain_name
@domain_name.setter
def domain_name(self, value):
""" Set domain_name value.
Notes:
Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
"""
self._domain_name = value
@property
def zone_id(self):
""" Get zone_id value.
Notes:
ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
"""
return self._zone_id
@zone_id.setter
def zone_id(self, value):
""" Set zone_id value.
Notes:
ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
"""
self._zone_id = value
@property
def zone_name(self):
""" Get zone_name value.
Notes:
Name of the zone that the VM is attached to.
This attribute is named `zoneName` in VSD API.
"""
return self._zone_name
@zone_name.setter
def zone_name(self, value):
""" Set zone_name value.
Notes:
Name of the zone that the VM is attached to.
This attribute is named `zoneName` in VSD API.
"""
self._zone_name = value
@property
def associated_floating_ip_address(self):
""" Get associated_floating_ip_address value.
Notes:
Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
"""
return self._associated_floating_ip_address
@associated_floating_ip_address.setter
def associated_floating_ip_address(self, value):
""" Set associated_floating_ip_address value.
Notes:
Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
"""
self._associated_floating_ip_address = value
@property
def attached_network_id(self):
""" Get attached_network_id value.
Notes:
ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
"""
return self._attached_network_id
@attached_network_id.setter
def attached_network_id(self, value):
""" Set attached_network_id value.
Notes:
ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
"""
self._attached_network_id = value
@property
def attached_network_type(self):
""" Get attached_network_type value.
Notes:
l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
"""
return self._attached_network_type
@attached_network_type.setter
def attached_network_type(self, value):
""" Set attached_network_type value.
Notes:
l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
"""
self._attached_network_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUBridgeInterface
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ATTACHED_NETWORK_TYPE_L2DOMAIN
var CONST_ATTACHED_NETWORK_TYPE_SUBNET
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_floating_ip_address
Get associated_floating_ip_address value.
Notes: Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
var attached_network_id
Get attached_network_id value.
Notes: ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
var attached_network_type
Get attached_network_type value.
Notes: l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var dhcp_options
var domain_id
Get domain_id value.
Notes: ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
var domain_name
Get domain_name value.
Notes: Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: Gateway of the subnet that the VM is connected to
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Device name associated with this interface
var netmask
Get netmask value.
Notes: Netmask of the subnet that the VM is attached to
var network_name
Get network_name value.
Notes: Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_decision_id
Get policy_decision_id value.
Notes: The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
var policy_decisions
var policy_groups
var qoss
var redirection_targets
var statistics
var tcas
var tier_id
Get tier_id value.
Notes: ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
var vport_id
Get vport_id value.
Notes: ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
var vport_name
Get vport_name value.
Notes: Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
var zone_id
Get zone_id value.
Notes: ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
var zone_name
Get zone_name value.
Notes: Name of the zone that the VM is attached to.
This attribute is named `zoneName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a BridgeInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> bridgeinterface = NUBridgeInterface(id=u'xxxx-xxx-xxx-xxx', name=u'BridgeInterface') >>> bridgeinterface = NUBridgeInterface(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a BridgeInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> bridgeinterface = NUBridgeInterface(id=u'xxxx-xxx-xxx-xxx', name=u'BridgeInterface')
>>> bridgeinterface = NUBridgeInterface(data=my_dict)
"""
super(NUBridgeInterface, self).__init__()
# Read/Write Attributes
self._vport_id = None
self._vport_name = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._netmask = None
self._network_name = None
self._tier_id = None
self._entity_scope = None
self._policy_decision_id = None
self._domain_id = None
self._domain_name = None
self._zone_id = None
self._zone_name = None
self._associated_floating_ip_address = None
self._attached_network_id = None
self._attached_network_type = None
self._external_id = None
self.expose_attribute(local_name="vport_id", remote_name="VPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tier_id", remote_name="tierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_decision_id", remote_name="policyDecisionID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_name", remote_name="zoneName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_address", remote_name="associatedFloatingIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_id", remote_name="attachedNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'L2DOMAIN', u'SUBNET'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_decisions = NUPolicyDecisionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUCertificate
Represents a Certificate in the VSD
Notes: This object represents a X509 Certificate Request
class NUCertificate(NURESTObject):
""" Represents a Certificate in the VSD
Notes:
This object represents a X509 Certificate Request
"""
__rest_name__ = "certificate"
__resource_name__ = "certificates"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a Certificate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> certificate = NUCertificate(id=u'xxxx-xxx-xxx-xxx', name=u'Certificate')
>>> certificate = NUCertificate(data=my_dict)
"""
super(NUCertificate, self).__init__()
# Read/Write Attributes
self._pem_encoded = None
self._serial_number = None
self._entity_scope = None
self._issuer_dn = None
self._subject_dn = None
self._public_key = None
self._external_id = None
self.expose_attribute(local_name="pem_encoded", remote_name="pemEncoded", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="serial_number", remote_name="serialNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="issuer_dn", remote_name="issuerDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subject_dn", remote_name="subjectDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_key", remote_name="publicKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def pem_encoded(self):
""" Get pem_encoded value.
Notes:
The PEM encoded certificate.
This attribute is named `pemEncoded` in VSD API.
"""
return self._pem_encoded
@pem_encoded.setter
def pem_encoded(self, value):
""" Set pem_encoded value.
Notes:
The PEM encoded certificate.
This attribute is named `pemEncoded` in VSD API.
"""
self._pem_encoded = value
@property
def serial_number(self):
""" Get serial_number value.
Notes:
The serial number of this certificate.
This attribute is named `serialNumber` in VSD API.
"""
return self._serial_number
@serial_number.setter
def serial_number(self, value):
""" Set serial_number value.
Notes:
The serial number of this certificate.
This attribute is named `serialNumber` in VSD API.
"""
self._serial_number = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def issuer_dn(self):
""" Get issuer_dn value.
Notes:
The distinguished name of the authority that issued this certificate.
This attribute is named `issuerDN` in VSD API.
"""
return self._issuer_dn
@issuer_dn.setter
def issuer_dn(self, value):
""" Set issuer_dn value.
Notes:
The distinguished name of the authority that issued this certificate.
This attribute is named `issuerDN` in VSD API.
"""
self._issuer_dn = value
@property
def subject_dn(self):
""" Get subject_dn value.
Notes:
The distinguished name of this certificate's end entity.
This attribute is named `subjectDN` in VSD API.
"""
return self._subject_dn
@subject_dn.setter
def subject_dn(self, value):
""" Set subject_dn value.
Notes:
The distinguished name of this certificate's end entity.
This attribute is named `subjectDN` in VSD API.
"""
self._subject_dn = value
@property
def public_key(self):
""" Get public_key value.
Notes:
The public key contained in this certificate.
This attribute is named `publicKey` in VSD API.
"""
return self._public_key
@public_key.setter
def public_key(self, value):
""" Set public_key value.
Notes:
The public key contained in this certificate.
This attribute is named `publicKey` in VSD API.
"""
self._public_key = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUCertificate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var issuer_dn
Get issuer_dn value.
Notes: The distinguished name of the authority that issued this certificate.
This attribute is named `issuerDN` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var pem_encoded
Get pem_encoded value.
Notes: The PEM encoded certificate.
This attribute is named `pemEncoded` in VSD API.
var public_key
Get public_key value.
Notes: The public key contained in this certificate.
This attribute is named `publicKey` in VSD API.
var serial_number
Get serial_number value.
Notes: The serial number of this certificate.
This attribute is named `serialNumber` in VSD API.
var subject_dn
Get subject_dn value.
Notes: The distinguished name of this certificate's end entity.
This attribute is named `subjectDN` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a Certificate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> certificate = NUCertificate(id=u'xxxx-xxx-xxx-xxx', name=u'Certificate') >>> certificate = NUCertificate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Certificate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> certificate = NUCertificate(id=u'xxxx-xxx-xxx-xxx', name=u'Certificate')
>>> certificate = NUCertificate(data=my_dict)
"""
super(NUCertificate, self).__init__()
# Read/Write Attributes
self._pem_encoded = None
self._serial_number = None
self._entity_scope = None
self._issuer_dn = None
self._subject_dn = None
self._public_key = None
self._external_id = None
self.expose_attribute(local_name="pem_encoded", remote_name="pemEncoded", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="serial_number", remote_name="serialNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="issuer_dn", remote_name="issuerDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subject_dn", remote_name="subjectDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_key", remote_name="publicKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUCloudMgmtSystem
Represents a CloudMgmtSystem in the VSD
Notes: Object that identifies a cloud management system.
class NUCloudMgmtSystem(NURESTObject):
""" Represents a CloudMgmtSystem in the VSD
Notes:
Object that identifies a cloud management system.
"""
__rest_name__ = "cms"
__resource_name__ = "cms"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a CloudMgmtSystem instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> cloudmgmtsystem = NUCloudMgmtSystem(id=u'xxxx-xxx-xxx-xxx', name=u'CloudMgmtSystem')
>>> cloudmgmtsystem = NUCloudMgmtSystem(data=my_dict)
"""
super(NUCloudMgmtSystem, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the cloud management system
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the cloud management system
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUCloudMgmtSystem
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the cloud management system
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a CloudMgmtSystem instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> cloudmgmtsystem = NUCloudMgmtSystem(id=u'xxxx-xxx-xxx-xxx', name=u'CloudMgmtSystem') >>> cloudmgmtsystem = NUCloudMgmtSystem(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a CloudMgmtSystem instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> cloudmgmtsystem = NUCloudMgmtSystem(id=u'xxxx-xxx-xxx-xxx', name=u'CloudMgmtSystem')
>>> cloudmgmtsystem = NUCloudMgmtSystem(data=my_dict)
"""
super(NUCloudMgmtSystem, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDHCPOption
Represents a DHCPOption in the VSD
Notes: Allows the definition of one or more DHCP options that will be provided to all VMs that are associated with a given domain. DHCP options are provided as Type- Length-Value (TLV). There is no validation by VSD on whether these options are valid or not. It is up to the user to guarantee that the options make sense for their application.
class NUDHCPOption(NURESTObject):
""" Represents a DHCPOption in the VSD
Notes:
Allows the definition of one or more DHCP options that will be provided to all VMs that are associated with a given domain. DHCP options are provided as Type- Length-Value (TLV). There is no validation by VSD on whether these options are valid or not. It is up to the user to guarantee that the options make sense for their application.
"""
__rest_name__ = "dhcpoption"
__resource_name__ = "dhcpoptions"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a DHCPOption instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> dhcpoption = NUDHCPOption(id=u'xxxx-xxx-xxx-xxx', name=u'DHCPOption')
>>> dhcpoption = NUDHCPOption(data=my_dict)
"""
super(NUDHCPOption, self).__init__()
# Read/Write Attributes
self._value = None
self._last_updated_by = None
self._actual_type = None
self._actual_values = None
self._length = None
self._entity_scope = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="value", remote_name="value", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="actual_type", remote_name="actualType", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="actual_values", remote_name="actualValues", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="length", remote_name="length", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def value(self):
""" Get value value.
Notes:
DHCP option value. Value should be a hexadecimal value(ie. Hex value 0xac40 would be passed as 'ac40')
"""
return self._value
@value.setter
def value(self, value):
""" Set value value.
Notes:
DHCP option value. Value should be a hexadecimal value(ie. Hex value 0xac40 would be passed as 'ac40')
"""
self._value = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def actual_type(self):
""" Get actual_type value.
Notes:
This will be used to send actual type instead of the hexadecimal. Note: If actualType is set, it will override the entry set in the type attribute
This attribute is named `actualType` in VSD API.
"""
return self._actual_type
@actual_type.setter
def actual_type(self, value):
""" Set actual_type value.
Notes:
This will be used to send actual type instead of the hexadecimal. Note: If actualType is set, it will override the entry set in the type attribute
This attribute is named `actualType` in VSD API.
"""
self._actual_type = value
@property
def actual_values(self):
""" Get actual_values value.
Notes:
This will be used to send actual values instead of the hexadecimal. Note: If actualValues are set, it will override entry set in the value attribute
This attribute is named `actualValues` in VSD API.
"""
return self._actual_values
@actual_values.setter
def actual_values(self, value):
""" Set actual_values value.
Notes:
This will be used to send actual values instead of the hexadecimal. Note: If actualValues are set, it will override entry set in the value attribute
This attribute is named `actualValues` in VSD API.
"""
self._actual_values = value
@property
def length(self):
""" Get length value.
Notes:
DHCP option length. Length should be a hexadecimal value(ie. Hex value 0x04 would be passed as '04')
"""
return self._length
@length.setter
def length(self, value):
""" Set length value.
Notes:
DHCP option length. Length should be a hexadecimal value(ie. Hex value 0x04 would be passed as '04')
"""
self._length = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
DHCP option type. Type should be a hexadecimal value(ie. Hex value 0x06 would be passed as '06')
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
DHCP option type. Type should be a hexadecimal value(ie. Hex value 0x06 would be passed as '06')
"""
self._type = value
Ancestors (in MRO)
- NUDHCPOption
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var actual_type
Get actual_type value.
Notes: This will be used to send actual type instead of the hexadecimal. Note: If actualType is set, it will override the entry set in the type attribute
This attribute is named `actualType` in VSD API.
var actual_values
Get actual_values value.
Notes: This will be used to send actual values instead of the hexadecimal. Note: If actualValues are set, it will override entry set in the value attribute
This attribute is named `actualValues` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var length
Get length value.
Notes: DHCP option length. Length should be a hexadecimal value(ie. Hex value 0x04 would be passed as '04')
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var type
Get type value.
Notes: DHCP option type. Type should be a hexadecimal value(ie. Hex value 0x06 would be passed as '06')
var value
Get value value.
Notes: DHCP option value. Value should be a hexadecimal value(ie. Hex value 0xac40 would be passed as 'ac40')
Methods
def __init__(
self, **kwargs)
Initializes a DHCPOption instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> dhcpoption = NUDHCPOption(id=u'xxxx-xxx-xxx-xxx', name=u'DHCPOption') >>> dhcpoption = NUDHCPOption(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a DHCPOption instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> dhcpoption = NUDHCPOption(id=u'xxxx-xxx-xxx-xxx', name=u'DHCPOption')
>>> dhcpoption = NUDHCPOption(data=my_dict)
"""
super(NUDHCPOption, self).__init__()
# Read/Write Attributes
self._value = None
self._last_updated_by = None
self._actual_type = None
self._actual_values = None
self._length = None
self._entity_scope = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="value", remote_name="value", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="actual_type", remote_name="actualType", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="actual_values", remote_name="actualValues", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="length", remote_name="length", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDSCPForwardingClassMapping
Represents a DSCPForwardingClassMapping in the VSD
Notes: Provides the definition of a single DSCP to a Forwarding class mapping that is part of a Table used in QoS policies.
class NUDSCPForwardingClassMapping(NURESTObject):
""" Represents a DSCPForwardingClassMapping in the VSD
Notes:
Provides the definition of a single DSCP to a Forwarding class mapping that is part of a Table used in QoS policies.
"""
__rest_name__ = "dscpforwardingclassmapping"
__resource_name__ = "dscpforwardingclassmappings"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_FORWARDING_CLASS_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_FORWARDING_CLASS_E = "E"
CONST_FORWARDING_CLASS_D = "D"
CONST_FORWARDING_CLASS_G = "G"
CONST_FORWARDING_CLASS_F = "F"
CONST_FORWARDING_CLASS_A = "A"
CONST_FORWARDING_CLASS_C = "C"
CONST_FORWARDING_CLASS_B = "B"
CONST_FORWARDING_CLASS_H = "H"
def __init__(self, **kwargs):
""" Initializes a DSCPForwardingClassMapping instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> dscpforwardingclassmapping = NUDSCPForwardingClassMapping(id=u'xxxx-xxx-xxx-xxx', name=u'DSCPForwardingClassMapping')
>>> dscpforwardingclassmapping = NUDSCPForwardingClassMapping(data=my_dict)
"""
super(NUDSCPForwardingClassMapping, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._entity_scope = None
self._forwarding_class = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="forwarding_class", remote_name="forwardingClass", attribute_type=str, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP value range from enumeration of 65 values : *, 0, 1, ..., 63
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP value range from enumeration of 65 values : *, 0, 1, ..., 63
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def forwarding_class(self):
""" Get forwarding_class value.
Notes:
Class of service to be used. Service classes in order of priority are A, B, C, D, E, F, G, and H.
This attribute is named `forwardingClass` in VSD API.
"""
return self._forwarding_class
@forwarding_class.setter
def forwarding_class(self, value):
""" Set forwarding_class value.
Notes:
Class of service to be used. Service classes in order of priority are A, B, C, D, E, F, G, and H.
This attribute is named `forwardingClass` in VSD API.
"""
self._forwarding_class = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUDSCPForwardingClassMapping
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_FORWARDING_CLASS_A
var CONST_FORWARDING_CLASS_B
var CONST_FORWARDING_CLASS_C
var CONST_FORWARDING_CLASS_D
var CONST_FORWARDING_CLASS_E
var CONST_FORWARDING_CLASS_F
var CONST_FORWARDING_CLASS_G
var CONST_FORWARDING_CLASS_H
var CONST_FORWARDING_CLASS_NONE
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var dscp
Get dscp value.
Notes: DSCP value range from enumeration of 65 values : *, 0, 1, ..., 63
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var forwarding_class
Get forwarding_class value.
Notes: Class of service to be used. Service classes in order of priority are A, B, C, D, E, F, G, and H.
This attribute is named `forwardingClass` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a DSCPForwardingClassMapping instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> dscpforwardingclassmapping = NUDSCPForwardingClassMapping(id=u'xxxx-xxx-xxx-xxx', name=u'DSCPForwardingClassMapping') >>> dscpforwardingclassmapping = NUDSCPForwardingClassMapping(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a DSCPForwardingClassMapping instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> dscpforwardingclassmapping = NUDSCPForwardingClassMapping(id=u'xxxx-xxx-xxx-xxx', name=u'DSCPForwardingClassMapping')
>>> dscpforwardingclassmapping = NUDSCPForwardingClassMapping(data=my_dict)
"""
super(NUDSCPForwardingClassMapping, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._entity_scope = None
self._forwarding_class = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="forwarding_class", remote_name="forwardingClass", attribute_type=str, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDSCPForwardingClassTable
Represents a DSCPForwardingClassTable in the VSD
Notes: Provides the definition of a table that holds multiple DSCP to Forwarding class mappings. Used in QoS policies.
class NUDSCPForwardingClassTable(NURESTObject):
""" Represents a DSCPForwardingClassTable in the VSD
Notes:
Provides the definition of a table that holds multiple DSCP to Forwarding class mappings. Used in QoS policies.
"""
__rest_name__ = "dscpforwardingclasstable"
__resource_name__ = "dscpforwardingclasstables"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a DSCPForwardingClassTable instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> dscpforwardingclasstable = NUDSCPForwardingClassTable(id=u'xxxx-xxx-xxx-xxx', name=u'DSCPForwardingClassTable')
>>> dscpforwardingclasstable = NUDSCPForwardingClassTable(data=my_dict)
"""
super(NUDSCPForwardingClassTable, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dscp_forwarding_class_mappings = NUDSCPForwardingClassMappingsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
A unique name of the dscp-fc mapping table.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
A unique name of the dscp-fc mapping table.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the dscp-fc mapping table.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the dscp-fc mapping table.
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUDSCPForwardingClassTable
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the dscp-fc mapping table.
var dscp_forwarding_class_mappings
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: A unique name of the dscp-fc mapping table.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a DSCPForwardingClassTable instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> dscpforwardingclasstable = NUDSCPForwardingClassTable(id=u'xxxx-xxx-xxx-xxx', name=u'DSCPForwardingClassTable') >>> dscpforwardingclasstable = NUDSCPForwardingClassTable(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a DSCPForwardingClassTable instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> dscpforwardingclasstable = NUDSCPForwardingClassTable(id=u'xxxx-xxx-xxx-xxx', name=u'DSCPForwardingClassTable')
>>> dscpforwardingclasstable = NUDSCPForwardingClassTable(data=my_dict)
"""
super(NUDSCPForwardingClassTable, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dscp_forwarding_class_mappings = NUDSCPForwardingClassMappingsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDiskStat
Represents a DiskStat in the VSD
Notes: Encapsulates the disk usage metrics for system monitor entity.
class NUDiskStat(NURESTObject):
""" Represents a DiskStat in the VSD
Notes:
Encapsulates the disk usage metrics for system monitor entity.
"""
__rest_name__ = "diskstat"
__resource_name__ = "diskstats"
## Constants
CONST_UNIT_KB = "KB"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_UNIT_MB = "MB"
CONST_UNIT_YB = "YB"
CONST_UNIT_BYTES = "Bytes"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_UNIT_ZB = "ZB"
CONST_UNIT_EB = "EB"
CONST_UNIT_PB = "PB"
CONST_UNIT_GB = "GB"
CONST_UNIT_TB = "TB"
def __init__(self, **kwargs):
""" Initializes a DiskStat instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> diskstat = NUDiskStat(id=u'xxxx-xxx-xxx-xxx', name=u'DiskStat')
>>> diskstat = NUDiskStat(data=my_dict)
"""
super(NUDiskStat, self).__init__()
# Read/Write Attributes
self._name = None
self._size = None
self._unit = None
self._entity_scope = None
self._used = None
self._available = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="size", remote_name="size", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="unit", remote_name="unit", attribute_type=str, is_required=False, is_unique=False, choices=[u'Bytes', u'EB', u'GB', u'KB', u'MB', u'PB', u'TB', u'YB', u'ZB'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="used", remote_name="used", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="available", remote_name="available", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the disk.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the disk.
"""
self._name = value
@property
def size(self):
""" Get size value.
Notes:
Total disk space.
"""
return self._size
@size.setter
def size(self, value):
""" Set size value.
Notes:
Total disk space.
"""
self._size = value
@property
def unit(self):
""" Get unit value.
Notes:
Storage unit type (example: bytes, KB, MB, etc.,).
"""
return self._unit
@unit.setter
def unit(self, value):
""" Set unit value.
Notes:
Storage unit type (example: bytes, KB, MB, etc.,).
"""
self._unit = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def used(self):
""" Get used value.
Notes:
Disk space used.
"""
return self._used
@used.setter
def used(self, value):
""" Set used value.
Notes:
Disk space used.
"""
self._used = value
@property
def available(self):
""" Get available value.
Notes:
Available disk space.
"""
return self._available
@available.setter
def available(self, value):
""" Set available value.
Notes:
Available disk space.
"""
self._available = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUDiskStat
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_UNIT_BYTES
var CONST_UNIT_EB
var CONST_UNIT_GB
var CONST_UNIT_KB
var CONST_UNIT_MB
var CONST_UNIT_PB
var CONST_UNIT_TB
var CONST_UNIT_YB
var CONST_UNIT_ZB
var resource_name
var rest_name
Instance variables
var available
Get available value.
Notes: Available disk space.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var name
Get name value.
Notes: Name of the disk.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var size
Get size value.
Notes: Total disk space.
var unit
Get unit value.
Notes: Storage unit type (example: bytes, KB, MB, etc.,).
var used
Get used value.
Notes: Disk space used.
Methods
def __init__(
self, **kwargs)
Initializes a DiskStat instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> diskstat = NUDiskStat(id=u'xxxx-xxx-xxx-xxx', name=u'DiskStat') >>> diskstat = NUDiskStat(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a DiskStat instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> diskstat = NUDiskStat(id=u'xxxx-xxx-xxx-xxx', name=u'DiskStat')
>>> diskstat = NUDiskStat(data=my_dict)
"""
super(NUDiskStat, self).__init__()
# Read/Write Attributes
self._name = None
self._size = None
self._unit = None
self._entity_scope = None
self._used = None
self._available = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="size", remote_name="size", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="unit", remote_name="unit", attribute_type=str, is_required=False, is_unique=False, choices=[u'Bytes', u'EB', u'GB', u'KB', u'MB', u'PB', u'TB', u'YB', u'ZB'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="used", remote_name="used", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="available", remote_name="available", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDomain
Represents a Domain in the VSD
Notes: This object is used to manipulate domain state. A domain corresponds to a distributed Virtual Router and Switch (dVRS).
class NUDomain(NURESTObject):
""" Represents a Domain in the VSD
Notes:
This object is used to manipulate domain state. A domain corresponds to a distributed Virtual Router and Switch (dVRS).
"""
__rest_name__ = "domain"
__resource_name__ = "domains"
## Constants
CONST_PAT_ENABLED_DISABLED = "DISABLED"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PAT_ENABLED_INHERITED = "INHERITED"
CONST_UPLINK_PREFERENCE_SECONDARY_PRIMARY = "SECONDARY_PRIMARY"
CONST_UPLINK_PREFERENCE_PRIMARY_SECONDARY = "PRIMARY_SECONDARY"
CONST_DHCP_BEHAVIOR_CONSUME = "CONSUME"
CONST_APPLICATION_DEPLOYMENT_POLICY_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_POLICY_CHANGE_STATUS_DISCARDED = "DISCARDED"
CONST_UNDERLAY_ENABLED_ENABLED = "ENABLED"
CONST_MAINTENANCE_MODE_DISABLED = "DISABLED"
CONST_TUNNEL_TYPE_DC_DEFAULT = "DC_DEFAULT"
CONST_MAINTENANCE_MODE_ENABLED = "ENABLED"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_UPLINK_PREFERENCE_SYMMETRIC = "SYMMETRIC"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_UNDERLAY_ENABLED_INHERITED = "INHERITED"
CONST_POLICY_CHANGE_STATUS_STARTED = "STARTED"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_DHCP_BEHAVIOR_RELAY = "RELAY"
CONST_APPLICATION_DEPLOYMENT_POLICY_ZONE = "ZONE"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PAT_ENABLED_ENABLED = "ENABLED"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_MULTICAST_INHERITED = "INHERITED"
CONST_UPLINK_PREFERENCE_SECONDARY = "SECONDARY"
CONST_DHCP_BEHAVIOR_FLOOD = "FLOOD"
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_TUNNEL_TYPE_VXLAN = "VXLAN"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_UPLINK_PREFERENCE_PRIMARY = "PRIMARY"
CONST_MAINTENANCE_MODE_ENABLED_INHERITED = "ENABLED_INHERITED"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_TUNNEL_TYPE_GRE = "GRE"
CONST_POLICY_CHANGE_STATUS_APPLIED = "APPLIED"
CONST_UNDERLAY_ENABLED_DISABLED = "DISABLED"
def __init__(self, **kwargs):
""" Initializes a Domain instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domain = NUDomain(id=u'xxxx-xxx-xxx-xxx', name=u'Domain')
>>> domain = NUDomain(data=my_dict)
"""
super(NUDomain, self).__init__()
# Read/Write Attributes
self._pat_enabled = None
self._ecmp_count = None
self._dhcp_behavior = None
self._dhcp_server_address = None
self._label_id = None
self._back_haul_route_distinguisher = None
self._back_haul_route_target = None
self._back_haul_vnid = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._leaking_enabled = None
self._secondary_dhcp_server_address = None
self._template_id = None
self._permitted_action = None
self._service_id = None
self._description = None
self._dhcp_server_addresses = None
self._global_routing_enabled = None
self._import_route_target = None
self._encryption = None
self._underlay_enabled = None
self._entity_scope = None
self._policy_change_status = None
self._route_distinguisher = None
self._route_target = None
self._uplink_preference = None
self._application_deployment_policy = None
self._associated_multicast_channel_map_id = None
self._stretched = None
self._multicast = None
self._tunnel_type = None
self._customer_id = None
self._export_route_target = None
self._external_id = None
self.expose_attribute(local_name="pat_enabled", remote_name="PATEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="ecmp_count", remote_name="ECMPCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_behavior", remote_name="DHCPBehavior", attribute_type=str, is_required=False, is_unique=False, choices=[u'CONSUME', u'FLOOD', u'RELAY'])
self.expose_attribute(local_name="dhcp_server_address", remote_name="DHCPServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="label_id", remote_name="labelID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="back_haul_route_distinguisher", remote_name="backHaulRouteDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="back_haul_route_target", remote_name="backHaulRouteTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="back_haul_vnid", remote_name="backHaulVNID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="leaking_enabled", remote_name="leakingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_dhcp_server_address", remote_name="secondaryDHCPServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="service_id", remote_name="serviceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_server_addresses", remote_name="dhcpServerAddresses", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="global_routing_enabled", remote_name="globalRoutingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="import_route_target", remote_name="importRouteTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="underlay_enabled", remote_name="underlayEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_target", remote_name="routeTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uplink_preference", remote_name="uplinkPreference", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'PRIMARY_SECONDARY', u'SECONDARY', u'SECONDARY_PRIMARY', u'SYMMETRIC'])
self.expose_attribute(local_name="application_deployment_policy", remote_name="applicationDeploymentPolicy", attribute_type=str, is_required=False, is_unique=False, choices=[u'NONE', u'ZONE'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stretched", remote_name="stretched", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="tunnel_type", remote_name="tunnelType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC_DEFAULT', u'GRE', u'VXLAN'])
self.expose_attribute(local_name="customer_id", remote_name="customerID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="export_route_target", remote_name="exportRouteTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domain_fip_acl_templates = NUDomainFIPAclTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ipacl_templates = NUFloatingIPACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ips = NUFloatingIpsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domains = NUDomainsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.domain_templates = NUDomainTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.zones = NUZonesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.uplink_rds = NUUplinkRDsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vpn_connections = NUVPNConnectionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bridge_interfaces = NUBridgeInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.external_app_services = NUExternalAppServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def pat_enabled(self):
""" Get pat_enabled value.
Notes:
Indicates whether PAT is enabled for the subnets in this domain - ENABLED/DISABLED Possible values are INHERITED, ENABLED, DISABLED, .
This attribute is named `PATEnabled` in VSD API.
"""
return self._pat_enabled
@pat_enabled.setter
def pat_enabled(self, value):
""" Set pat_enabled value.
Notes:
Indicates whether PAT is enabled for the subnets in this domain - ENABLED/DISABLED Possible values are INHERITED, ENABLED, DISABLED, .
This attribute is named `PATEnabled` in VSD API.
"""
self._pat_enabled = value
@property
def ecmp_count(self):
""" Get ecmp_count value.
Notes:
Domain specific Equal-cost multi-path routing count, ECMPCount = 1 means no ECMP
This attribute is named `ECMPCount` in VSD API.
"""
return self._ecmp_count
@ecmp_count.setter
def ecmp_count(self, value):
""" Set ecmp_count value.
Notes:
Domain specific Equal-cost multi-path routing count, ECMPCount = 1 means no ECMP
This attribute is named `ECMPCount` in VSD API.
"""
self._ecmp_count = value
@property
def dhcp_behavior(self):
""" Get dhcp_behavior value.
Notes:
DHCPBehaviorType is an enum that indicates DHCP Behavior of VRS having VM's under this domain. Possible values are FLOOD, CONSUME ,RELAY Possible values are CONSUME, FLOOD, RELAY, .
This attribute is named `DHCPBehavior` in VSD API.
"""
return self._dhcp_behavior
@dhcp_behavior.setter
def dhcp_behavior(self, value):
""" Set dhcp_behavior value.
Notes:
DHCPBehaviorType is an enum that indicates DHCP Behavior of VRS having VM's under this domain. Possible values are FLOOD, CONSUME ,RELAY Possible values are CONSUME, FLOOD, RELAY, .
This attribute is named `DHCPBehavior` in VSD API.
"""
self._dhcp_behavior = value
@property
def dhcp_server_address(self):
""" Get dhcp_server_address value.
Notes:
when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `DHCPServerAddress` in VSD API.
"""
return self._dhcp_server_address
@dhcp_server_address.setter
def dhcp_server_address(self, value):
""" Set dhcp_server_address value.
Notes:
when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `DHCPServerAddress` in VSD API.
"""
self._dhcp_server_address = value
@property
def label_id(self):
""" Get label_id value.
Notes:
The label associated with the dVRS. This is a read only attribute
This attribute is named `labelID` in VSD API.
"""
return self._label_id
@label_id.setter
def label_id(self, value):
""" Set label_id value.
Notes:
The label associated with the dVRS. This is a read only attribute
This attribute is named `labelID` in VSD API.
"""
self._label_id = value
@property
def back_haul_route_distinguisher(self):
""" Get back_haul_route_distinguisher value.
Notes:
Route distinguisher associated with the BackHaul Service in dVRS. If not provided during creation, System generates this identifier automatically
This attribute is named `backHaulRouteDistinguisher` in VSD API.
"""
return self._back_haul_route_distinguisher
@back_haul_route_distinguisher.setter
def back_haul_route_distinguisher(self, value):
""" Set back_haul_route_distinguisher value.
Notes:
Route distinguisher associated with the BackHaul Service in dVRS. If not provided during creation, System generates this identifier automatically
This attribute is named `backHaulRouteDistinguisher` in VSD API.
"""
self._back_haul_route_distinguisher = value
@property
def back_haul_route_target(self):
""" Get back_haul_route_target value.
Notes:
Route target associated with the BackHaul Service in dVRS. If not provided during creation, System generates this identifier automatically
This attribute is named `backHaulRouteTarget` in VSD API.
"""
return self._back_haul_route_target
@back_haul_route_target.setter
def back_haul_route_target(self, value):
""" Set back_haul_route_target value.
Notes:
Route target associated with the BackHaul Service in dVRS. If not provided during creation, System generates this identifier automatically
This attribute is named `backHaulRouteTarget` in VSD API.
"""
self._back_haul_route_target = value
@property
def back_haul_vnid(self):
""" Get back_haul_vnid value.
Notes:
Current BackHaul Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `backHaulVNID` in VSD API.
"""
return self._back_haul_vnid
@back_haul_vnid.setter
def back_haul_vnid(self, value):
""" Set back_haul_vnid value.
Notes:
Current BackHaul Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `backHaulVNID` in VSD API.
"""
self._back_haul_vnid = value
@property
def maintenance_mode(self):
""" Get maintenance_mode value.
Notes:
maintenanceMode is an enum that indicates if the Domain is accepting VM activation requests. Possible values are DISABLED, ENABLED and ENABLED_INHERITED Possible values are .
This attribute is named `maintenanceMode` in VSD API.
"""
return self._maintenance_mode
@maintenance_mode.setter
def maintenance_mode(self, value):
""" Set maintenance_mode value.
Notes:
maintenanceMode is an enum that indicates if the Domain is accepting VM activation requests. Possible values are DISABLED, ENABLED and ENABLED_INHERITED Possible values are .
This attribute is named `maintenanceMode` in VSD API.
"""
self._maintenance_mode = value
@property
def name(self):
""" Get name value.
Notes:
The name of the domain. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the domain. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def leaking_enabled(self):
""" Get leaking_enabled value.
Notes:
Indicates if this domain is a leakable domain or not - boolean true/false
This attribute is named `leakingEnabled` in VSD API.
"""
return self._leaking_enabled
@leaking_enabled.setter
def leaking_enabled(self, value):
""" Set leaking_enabled value.
Notes:
Indicates if this domain is a leakable domain or not - boolean true/false
This attribute is named `leakingEnabled` in VSD API.
"""
self._leaking_enabled = value
@property
def secondary_dhcp_server_address(self):
""" Get secondary_dhcp_server_address value.
Notes:
when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `secondaryDHCPServerAddress` in VSD API.
"""
return self._secondary_dhcp_server_address
@secondary_dhcp_server_address.setter
def secondary_dhcp_server_address(self, value):
""" Set secondary_dhcp_server_address value.
Notes:
when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `secondaryDHCPServerAddress` in VSD API.
"""
self._secondary_dhcp_server_address = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the template that this domain was created from. This should be set when instantiating a domain
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the template that this domain was created from. This should be set when instantiating a domain
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/DEPLOY for the Domain Possible values are USE, READ, ALL, INSTANTIATE, EXTEND, DEPLOY, .
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/DEPLOY for the Domain Possible values are USE, READ, ALL, INSTANTIATE, EXTEND, DEPLOY, .
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def service_id(self):
""" Get service_id value.
Notes:
The serviceID of the Virtual Router created in VSC and is associated with this object. This is auto-generated by VSD
This attribute is named `serviceID` in VSD API.
"""
return self._service_id
@service_id.setter
def service_id(self, value):
""" Set service_id value.
Notes:
The serviceID of the Virtual Router created in VSC and is associated with this object. This is auto-generated by VSD
This attribute is named `serviceID` in VSD API.
"""
self._service_id = value
@property
def description(self):
""" Get description value.
Notes:
A description string of the domain that is provided by the user
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description string of the domain that is provided by the user
"""
self._description = value
@property
def dhcp_server_addresses(self):
""" Get dhcp_server_addresses value.
Notes:
when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `dhcpServerAddresses` in VSD API.
"""
return self._dhcp_server_addresses
@dhcp_server_addresses.setter
def dhcp_server_addresses(self, value):
""" Set dhcp_server_addresses value.
Notes:
when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `dhcpServerAddresses` in VSD API.
"""
self._dhcp_server_addresses = value
@property
def global_routing_enabled(self):
""" Get global_routing_enabled value.
Notes:
Indicates if this domain is a globally routable domain or not - boolean true/false
This attribute is named `globalRoutingEnabled` in VSD API.
"""
return self._global_routing_enabled
@global_routing_enabled.setter
def global_routing_enabled(self, value):
""" Set global_routing_enabled value.
Notes:
Indicates if this domain is a globally routable domain or not - boolean true/false
This attribute is named `globalRoutingEnabled` in VSD API.
"""
self._global_routing_enabled = value
@property
def import_route_target(self):
""" Get import_route_target value.
Notes:
Route distinguisher associated with the dVRS. It is an optional parameter that can be provided by the user or auto-managed by VSD. System generates this identifier automatically, if not provided
This attribute is named `importRouteTarget` in VSD API.
"""
return self._import_route_target
@import_route_target.setter
def import_route_target(self, value):
""" Set import_route_target value.
Notes:
Route distinguisher associated with the dVRS. It is an optional parameter that can be provided by the user or auto-managed by VSD. System generates this identifier automatically, if not provided
This attribute is named `importRouteTarget` in VSD API.
"""
self._import_route_target = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
"""
self._encryption = value
@property
def underlay_enabled(self):
""" Get underlay_enabled value.
Notes:
Indicates whether UNDERLAY is enabled for the subnets in this domain
This attribute is named `underlayEnabled` in VSD API.
"""
return self._underlay_enabled
@underlay_enabled.setter
def underlay_enabled(self, value):
""" Set underlay_enabled value.
Notes:
Indicates whether UNDERLAY is enabled for the subnets in this domain
This attribute is named `underlayEnabled` in VSD API.
"""
self._underlay_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_change_status(self):
""" Get policy_change_status value.
Notes:
None
This attribute is named `policyChangeStatus` in VSD API.
"""
return self._policy_change_status
@policy_change_status.setter
def policy_change_status(self, value):
""" Set policy_change_status value.
Notes:
None
This attribute is named `policyChangeStatus` in VSD API.
"""
self._policy_change_status = value
@property
def route_distinguisher(self):
""" Get route_distinguisher value.
Notes:
Route distinguisher associated with the dVRS. It is an optional parameter that can be provided by the user or auto-managed by VSD. System generates this identifier automatically, if not provided
This attribute is named `routeDistinguisher` in VSD API.
"""
return self._route_distinguisher
@route_distinguisher.setter
def route_distinguisher(self, value):
""" Set route_distinguisher value.
Notes:
Route distinguisher associated with the dVRS. It is an optional parameter that can be provided by the user or auto-managed by VSD. System generates this identifier automatically, if not provided
This attribute is named `routeDistinguisher` in VSD API.
"""
self._route_distinguisher = value
@property
def route_target(self):
""" Get route_target value.
Notes:
Route target associated with the dVRS. It is an optional parameterthat can be provided by the user or auto-managed by VSDSystem generates this identifier automatically, if not provided
This attribute is named `routeTarget` in VSD API.
"""
return self._route_target
@route_target.setter
def route_target(self, value):
""" Set route_target value.
Notes:
Route target associated with the dVRS. It is an optional parameterthat can be provided by the user or auto-managed by VSDSystem generates this identifier automatically, if not provided
This attribute is named `routeTarget` in VSD API.
"""
self._route_target = value
@property
def uplink_preference(self):
""" Get uplink_preference value.
Notes:
Indicates the preferencial path selection for network traffic in this domain - Default is Primary 1 and Secondary 2. Possible values are PRIMARY_SECONDARY, SECONDARY_PRIMARY, PRIMARY, SECONDARY, SYMMETRIC, .
This attribute is named `uplinkPreference` in VSD API.
"""
return self._uplink_preference
@uplink_preference.setter
def uplink_preference(self, value):
""" Set uplink_preference value.
Notes:
Indicates the preferencial path selection for network traffic in this domain - Default is Primary 1 and Secondary 2. Possible values are PRIMARY_SECONDARY, SECONDARY_PRIMARY, PRIMARY, SECONDARY, SYMMETRIC, .
This attribute is named `uplinkPreference` in VSD API.
"""
self._uplink_preference = value
@property
def application_deployment_policy(self):
""" Get application_deployment_policy value.
Notes:
Application deployment policy.
This attribute is named `applicationDeploymentPolicy` in VSD API.
"""
return self._application_deployment_policy
@application_deployment_policy.setter
def application_deployment_policy(self, value):
""" Set application_deployment_policy value.
Notes:
Application deployment policy.
This attribute is named `applicationDeploymentPolicy` in VSD API.
"""
self._application_deployment_policy = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this domain is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this domain is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def stretched(self):
""" Get stretched value.
Notes:
Indicates whether this domain is streched,if so remote VM resolutions will be allowed
"""
return self._stretched
@stretched.setter
def stretched(self, value):
""" Set stretched value.
Notes:
Indicates whether this domain is streched,if so remote VM resolutions will be allowed
"""
self._stretched = value
@property
def multicast(self):
""" Get multicast value.
Notes:
multicast is enum that indicates multicast policy on domain. Possible values are ENABLED ,DISABLED and INHERITED Possible values are INHERITED, ENABLED, DISABLED, .
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
multicast is enum that indicates multicast policy on domain. Possible values are ENABLED ,DISABLED and INHERITED Possible values are INHERITED, ENABLED, DISABLED, .
"""
self._multicast = value
@property
def tunnel_type(self):
""" Get tunnel_type value.
Notes:
Default Domain Tunnel Type
This attribute is named `tunnelType` in VSD API.
"""
return self._tunnel_type
@tunnel_type.setter
def tunnel_type(self, value):
""" Set tunnel_type value.
Notes:
Default Domain Tunnel Type
This attribute is named `tunnelType` in VSD API.
"""
self._tunnel_type = value
@property
def customer_id(self):
""" Get customer_id value.
Notes:
The customerID that is created in the VSC and identifies this dVRS. This is auto-generated by VSD
This attribute is named `customerID` in VSD API.
"""
return self._customer_id
@customer_id.setter
def customer_id(self, value):
""" Set customer_id value.
Notes:
The customerID that is created in the VSC and identifies this dVRS. This is auto-generated by VSD
This attribute is named `customerID` in VSD API.
"""
self._customer_id = value
@property
def export_route_target(self):
""" Get export_route_target value.
Notes:
Route target associated with the dVRS. It is an optional parameterthat can be provided by the user or auto-managed by VSDSystem generates this identifier automatically, if not provided
This attribute is named `exportRouteTarget` in VSD API.
"""
return self._export_route_target
@export_route_target.setter
def export_route_target(self, value):
""" Set export_route_target value.
Notes:
Route target associated with the dVRS. It is an optional parameterthat can be provided by the user or auto-managed by VSDSystem generates this identifier automatically, if not provided
This attribute is named `exportRouteTarget` in VSD API.
"""
self._export_route_target = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUDomain
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_APPLICATION_DEPLOYMENT_POLICY_NONE
var CONST_APPLICATION_DEPLOYMENT_POLICY_ZONE
var CONST_DHCP_BEHAVIOR_CONSUME
var CONST_DHCP_BEHAVIOR_FLOOD
var CONST_DHCP_BEHAVIOR_RELAY
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MAINTENANCE_MODE_DISABLED
var CONST_MAINTENANCE_MODE_ENABLED
var CONST_MAINTENANCE_MODE_ENABLED_INHERITED
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var CONST_PAT_ENABLED_DISABLED
var CONST_PAT_ENABLED_ENABLED
var CONST_PAT_ENABLED_INHERITED
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_POLICY_CHANGE_STATUS_APPLIED
var CONST_POLICY_CHANGE_STATUS_DISCARDED
var CONST_POLICY_CHANGE_STATUS_STARTED
var CONST_TUNNEL_TYPE_DC_DEFAULT
var CONST_TUNNEL_TYPE_GRE
var CONST_TUNNEL_TYPE_VXLAN
var CONST_UNDERLAY_ENABLED_DISABLED
var CONST_UNDERLAY_ENABLED_ENABLED
var CONST_UNDERLAY_ENABLED_INHERITED
var CONST_UPLINK_PREFERENCE_PRIMARY
var CONST_UPLINK_PREFERENCE_PRIMARY_SECONDARY
var CONST_UPLINK_PREFERENCE_SECONDARY
var CONST_UPLINK_PREFERENCE_SECONDARY_PRIMARY
var CONST_UPLINK_PREFERENCE_SYMMETRIC
var resource_name
var rest_name
Instance variables
var application_deployment_policy
Get application_deployment_policy value.
Notes: Application deployment policy.
This attribute is named `applicationDeploymentPolicy` in VSD API.
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this domain is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
var back_haul_route_distinguisher
Get back_haul_route_distinguisher value.
Notes: Route distinguisher associated with the BackHaul Service in dVRS. If not provided during creation, System generates this identifier automatically
This attribute is named `backHaulRouteDistinguisher` in VSD API.
var back_haul_route_target
Get back_haul_route_target value.
Notes: Route target associated with the BackHaul Service in dVRS. If not provided during creation, System generates this identifier automatically
This attribute is named `backHaulRouteTarget` in VSD API.
var back_haul_vnid
Get back_haul_vnid value.
Notes: Current BackHaul Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `backHaulVNID` in VSD API.
var bridge_interfaces
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var customer_id
Get customer_id value.
Notes: The customerID that is created in the VSC and identifies this dVRS. This is auto-generated by VSD
This attribute is named `customerID` in VSD API.
var description
Get description value.
Notes: A description string of the domain that is provided by the user
var dhcp_behavior
Get dhcp_behavior value.
Notes: DHCPBehaviorType is an enum that indicates DHCP Behavior of VRS having VM's under this domain. Possible values are FLOOD, CONSUME ,RELAY Possible values are CONSUME, FLOOD, RELAY, .
This attribute is named `DHCPBehavior` in VSD API.
var dhcp_options
var dhcp_server_address
Get dhcp_server_address value.
Notes: when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `DHCPServerAddress` in VSD API.
var dhcp_server_addresses
Get dhcp_server_addresses value.
Notes: when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `dhcpServerAddresses` in VSD API.
var domain_fip_acl_templates
var domain_templates
var domains
var ecmp_count
Get ecmp_count value.
Notes: Domain specific Equal-cost multi-path routing count, ECMPCount = 1 means no ECMP
This attribute is named `ECMPCount` in VSD API.
var egress_acl_entry_templates
var egress_acl_templates
var encryption
Get encryption value.
Notes: Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var export_route_target
Get export_route_target value.
Notes: Route target associated with the dVRS. It is an optional parameterthat can be provided by the user or auto-managed by VSDSystem generates this identifier automatically, if not provided
This attribute is named `exportRouteTarget` in VSD API.
var external_app_services
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var floating_ipacl_templates
var floating_ips
var global_metadatas
var global_routing_enabled
Get global_routing_enabled value.
Notes: Indicates if this domain is a globally routable domain or not - boolean true/false
This attribute is named `globalRoutingEnabled` in VSD API.
var groups
var host_interfaces
var id
Get object id
var import_route_target
Get import_route_target value.
Notes: Route distinguisher associated with the dVRS. It is an optional parameter that can be provided by the user or auto-managed by VSD. System generates this identifier automatically, if not provided
This attribute is named `importRouteTarget` in VSD API.
var ingress_acl_entry_templates
var ingress_acl_templates
var ingress_adv_fwd_templates
var ingress_external_service_templates
var jobs
var label_id
Get label_id value.
Notes: The label associated with the dVRS. This is a read only attribute
This attribute is named `labelID` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var leaking_enabled
Get leaking_enabled value.
Notes: Indicates if this domain is a leakable domain or not - boolean true/false
This attribute is named `leakingEnabled` in VSD API.
var local_id
Get local id
var maintenance_mode
Get maintenance_mode value.
Notes: maintenanceMode is an enum that indicates if the Domain is accepting VM activation requests. Possible values are DISABLED, ENABLED and ENABLED_INHERITED Possible values are .
This attribute is named `maintenanceMode` in VSD API.
var metadatas
var multicast
Get multicast value.
Notes: multicast is enum that indicates multicast policy on domain. Possible values are ENABLED ,DISABLED and INHERITED Possible values are INHERITED, ENABLED, DISABLED, .
var name
Get name value.
Notes: The name of the domain. Valid characters are alphabets, numbers, space and hyphen( - ).
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var pat_enabled
Get pat_enabled value.
Notes: Indicates whether PAT is enabled for the subnets in this domain - ENABLED/DISABLED Possible values are INHERITED, ENABLED, DISABLED, .
This attribute is named `PATEnabled` in VSD API.
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/DEPLOY for the Domain Possible values are USE, READ, ALL, INSTANTIATE, EXTEND, DEPLOY, .
This attribute is named `permittedAction` in VSD API.
var policy_change_status
Get policy_change_status value.
Notes: None
This attribute is named `policyChangeStatus` in VSD API.
var policy_groups
var qoss
var redirection_targets
var route_distinguisher
Get route_distinguisher value.
Notes: Route distinguisher associated with the dVRS. It is an optional parameter that can be provided by the user or auto-managed by VSD. System generates this identifier automatically, if not provided
This attribute is named `routeDistinguisher` in VSD API.
var route_target
Get route_target value.
Notes: Route target associated with the dVRS. It is an optional parameterthat can be provided by the user or auto-managed by VSDSystem generates this identifier automatically, if not provided
This attribute is named `routeTarget` in VSD API.
var secondary_dhcp_server_address
Get secondary_dhcp_server_address value.
Notes: when DHCPBehaviorType is RELAY, then DHCP Server IP Address needs to be set
This attribute is named `secondaryDHCPServerAddress` in VSD API.
var service_id
Get service_id value.
Notes: The serviceID of the Virtual Router created in VSC and is associated with this object. This is auto-generated by VSD
This attribute is named `serviceID` in VSD API.
var static_routes
var statistics
var statistics_policies
var stretched
Get stretched value.
Notes: Indicates whether this domain is streched,if so remote VM resolutions will be allowed
var subnets
var tcas
var template_id
Get template_id value.
Notes: The ID of the template that this domain was created from. This should be set when instantiating a domain
This attribute is named `templateID` in VSD API.
var tunnel_type
Get tunnel_type value.
Notes: Default Domain Tunnel Type
This attribute is named `tunnelType` in VSD API.
var underlay_enabled
Get underlay_enabled value.
Notes: Indicates whether UNDERLAY is enabled for the subnets in this domain
This attribute is named `underlayEnabled` in VSD API.
var uplink_preference
Get uplink_preference value.
Notes: Indicates the preferencial path selection for network traffic in this domain - Default is Primary 1 and Secondary 2. Possible values are PRIMARY_SECONDARY, SECONDARY_PRIMARY, PRIMARY, SECONDARY, SYMMETRIC, .
This attribute is named `uplinkPreference` in VSD API.
var uplink_rds
var vm_interfaces
var vms
var vpn_connections
var vports
var zones
Methods
def __init__(
self, **kwargs)
Initializes a Domain instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> domain = NUDomain(id=u'xxxx-xxx-xxx-xxx', name=u'Domain') >>> domain = NUDomain(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Domain instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domain = NUDomain(id=u'xxxx-xxx-xxx-xxx', name=u'Domain')
>>> domain = NUDomain(data=my_dict)
"""
super(NUDomain, self).__init__()
# Read/Write Attributes
self._pat_enabled = None
self._ecmp_count = None
self._dhcp_behavior = None
self._dhcp_server_address = None
self._label_id = None
self._back_haul_route_distinguisher = None
self._back_haul_route_target = None
self._back_haul_vnid = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._leaking_enabled = None
self._secondary_dhcp_server_address = None
self._template_id = None
self._permitted_action = None
self._service_id = None
self._description = None
self._dhcp_server_addresses = None
self._global_routing_enabled = None
self._import_route_target = None
self._encryption = None
self._underlay_enabled = None
self._entity_scope = None
self._policy_change_status = None
self._route_distinguisher = None
self._route_target = None
self._uplink_preference = None
self._application_deployment_policy = None
self._associated_multicast_channel_map_id = None
self._stretched = None
self._multicast = None
self._tunnel_type = None
self._customer_id = None
self._export_route_target = None
self._external_id = None
self.expose_attribute(local_name="pat_enabled", remote_name="PATEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="ecmp_count", remote_name="ECMPCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_behavior", remote_name="DHCPBehavior", attribute_type=str, is_required=False, is_unique=False, choices=[u'CONSUME', u'FLOOD', u'RELAY'])
self.expose_attribute(local_name="dhcp_server_address", remote_name="DHCPServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="label_id", remote_name="labelID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="back_haul_route_distinguisher", remote_name="backHaulRouteDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="back_haul_route_target", remote_name="backHaulRouteTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="back_haul_vnid", remote_name="backHaulVNID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="leaking_enabled", remote_name="leakingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_dhcp_server_address", remote_name="secondaryDHCPServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="service_id", remote_name="serviceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_server_addresses", remote_name="dhcpServerAddresses", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="global_routing_enabled", remote_name="globalRoutingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="import_route_target", remote_name="importRouteTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="underlay_enabled", remote_name="underlayEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_target", remote_name="routeTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uplink_preference", remote_name="uplinkPreference", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'PRIMARY_SECONDARY', u'SECONDARY', u'SECONDARY_PRIMARY', u'SYMMETRIC'])
self.expose_attribute(local_name="application_deployment_policy", remote_name="applicationDeploymentPolicy", attribute_type=str, is_required=False, is_unique=False, choices=[u'NONE', u'ZONE'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stretched", remote_name="stretched", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="tunnel_type", remote_name="tunnelType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC_DEFAULT', u'GRE', u'VXLAN'])
self.expose_attribute(local_name="customer_id", remote_name="customerID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="export_route_target", remote_name="exportRouteTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domain_fip_acl_templates = NUDomainFIPAclTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ipacl_templates = NUFloatingIPACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ips = NUFloatingIpsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domains = NUDomainsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.domain_templates = NUDomainTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.zones = NUZonesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.uplink_rds = NUUplinkRDsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vpn_connections = NUVPNConnectionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bridge_interfaces = NUBridgeInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.external_app_services = NUExternalAppServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDomainFIPAclTemplate
Represents a DomainFIPAclTemplate in the VSD
Notes: Defines the template for an Domain Floating IP ACL
class NUDomainFIPAclTemplate(NURESTObject):
""" Represents a DomainFIPAclTemplate in the VSD
Notes:
Defines the template for an Domain Floating IP ACL
"""
__rest_name__ = "egressdomainfloatingipacltemplate"
__resource_name__ = "egressdomainfloatingipacltemplates"
## Constants
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PRIORITY_TYPE_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PRIORITY_TYPE_TOP = "TOP"
CONST_PRIORITY_TYPE_BOTTOM = "BOTTOM"
def __init__(self, **kwargs):
""" Initializes a DomainFIPAclTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domainfipacltemplate = NUDomainFIPAclTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'DomainFIPAclTemplate')
>>> domainfipacltemplate = NUDomainFIPAclTemplate(data=my_dict)
"""
super(NUDomainFIPAclTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._description = None
self._entity_scope = None
self._entries = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="entries", remote_name="entries", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domain_fip_acl_template_entries = NUDomainFIPAclTemplateEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The name of the entity
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the entity
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def active(self):
""" Get active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
self._active = value
@property
def default_allow_ip(self):
""" Get default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
return self._default_allow_ip
@default_allow_ip.setter
def default_allow_ip(self, value):
""" Set default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
self._default_allow_ip = value
@property
def default_allow_non_ip(self):
""" Get default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
return self._default_allow_non_ip
@default_allow_non_ip.setter
def default_allow_non_ip(self, value):
""" Set default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
self._default_allow_non_ip = value
@property
def description(self):
""" Get description value.
Notes:
A description of the entity
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the entity
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def entries(self):
""" Get entries value.
Notes:
List of Egress Domain ACL entries associated with this ACL
"""
return self._entries
@entries.setter
def entries(self, value):
""" Set entries value.
Notes:
List of Egress Domain ACL entries associated with this ACL
"""
self._entries = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def priority_type(self):
""" Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
return self._priority_type
@priority_type.setter
def priority_type(self, value):
""" Set priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
self._priority_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUDomainFIPAclTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_PRIORITY_TYPE_BOTTOM
var CONST_PRIORITY_TYPE_NONE
var CONST_PRIORITY_TYPE_TOP
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: If enabled, it means that this ACL or QOS entry is active
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var default_allow_ip
Get default_allow_ip value.
Notes: If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
var default_allow_non_ip
Get default_allow_non_ip value.
Notes: If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
var description
Get description value.
Notes: A description of the entity
var domain_fip_acl_template_entries
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var entries
Get entries value.
Notes: List of Egress Domain ACL entries associated with this ACL
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: The name of the entity
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var priority_type
Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a DomainFIPAclTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> domainfipacltemplate = NUDomainFIPAclTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'DomainFIPAclTemplate') >>> domainfipacltemplate = NUDomainFIPAclTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a DomainFIPAclTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domainfipacltemplate = NUDomainFIPAclTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'DomainFIPAclTemplate')
>>> domainfipacltemplate = NUDomainFIPAclTemplate(data=my_dict)
"""
super(NUDomainFIPAclTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._description = None
self._entity_scope = None
self._entries = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="entries", remote_name="entries", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domain_fip_acl_template_entries = NUDomainFIPAclTemplateEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDomainFIPAclTemplateEntry
Represents a DomainFIPAclTemplateEntry in the VSD
Notes: Defines the template of Egress Domain ACL Template entries
class NUDomainFIPAclTemplateEntry(NURESTObject):
""" Represents a DomainFIPAclTemplateEntry in the VSD
Notes:
Defines the template of Egress Domain ACL Template entries
"""
__rest_name__ = "egressdomainfloatingipaclentrytemplate"
__resource_name__ = "egressdomainfloatingipaclentrytemplates"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ACTION_REDIRECT = "REDIRECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_NETWORK_TYPE_ENDPOINT_ZONE = "ENDPOINT_ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_LOCATION_TYPE_ANY = "ANY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_NETWORK_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_DESTINATION_TYPE_NETWORK = "NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_NETWORK_TYPE_ENDPOINT_DOMAIN = "ENDPOINT_DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_NETWORK_TYPE_ANY = "ANY"
CONST_LOCATION_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_NETWORK_TYPE_INTERNET_POLICYGROUP = "INTERNET_POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_LOCATION_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_LOCATION_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_LOCATION_TYPE_REDIRECTIONTARGET = "REDIRECTIONTARGET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ACTION_DROP = "DROP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_SOURCE_TYPE_NETWORKPOLICYGROUP = "NETWORKPOLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_SOURCE_TYPE_NETWORK = "NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_DESTINATION_TYPE_NETWORKPOLICYGROUP = "NETWORKPOLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_DESTINATION_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_LOCATION_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_NETWORK_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ACTION_FORWARD = "FORWARD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_NETWORK_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_NETWORK_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_SOURCE_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_NETWORK_TYPE_ENDPOINT_SUBNET = "ENDPOINT_SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
def __init__(self, **kwargs):
""" Initializes a DomainFIPAclTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domainfipacltemplateentry = NUDomainFIPAclTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'DomainFIPAclTemplateEntry')
>>> domainfipacltemplateentry = NUDomainFIPAclTemplateEntry(data=my_dict)
"""
super(NUDomainFIPAclTemplateEntry, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._action_details = None
self._address_override = None
self._reflexive = None
self._description = None
self._dest_pg_id = None
self._dest_pg_type = None
self._destination_port = None
self._destination_type = None
self._destination_value = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_pg_id = None
self._source_pg_type = None
self._source_port = None
self._source_type = None
self._source_value = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="action_details", remote_name="actionDetails", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dest_pg_id", remote_name="destPgId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dest_pg_type", remote_name="destPgType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_type", remote_name="destinationType", attribute_type=str, is_required=False, is_unique=False, choices=[u'NETWORK', u'NETWORKPOLICYGROUP', u'POLICYGROUP'])
self.expose_attribute(local_name="destination_value", remote_name="destinationValue", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_pg_id", remote_name="sourcePgId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_pg_type", remote_name="sourcePgType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_type", remote_name="sourceType", attribute_type=str, is_required=False, is_unique=False, choices=[u'NETWORK', u'NETWORKPOLICYGROUP', u'POLICYGROUP'])
self.expose_attribute(local_name="source_value", remote_name="sourceValue", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def action(self):
""" Get action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
"""
self._action = value
@property
def action_details(self):
""" Get action_details value.
Notes:
Type of action to be performed when a ACL match criteria succeeds
This attribute is named `actionDetails` in VSD API.
"""
return self._action_details
@action_details.setter
def action_details(self, value):
""" Set action_details value.
Notes:
Type of action to be performed when a ACL match criteria succeeds
This attribute is named `actionDetails` in VSD API.
"""
self._action_details = value
@property
def address_override(self):
""" Get address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
return self._address_override
@address_override.setter
def address_override(self, value):
""" Set address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
self._address_override = value
@property
def reflexive(self):
""" Get reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
return self._reflexive
@reflexive.setter
def reflexive(self, value):
""" Set reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
self._reflexive = value
@property
def description(self):
""" Get description value.
Notes:
Description of the ACL entry
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the ACL entry
"""
self._description = value
@property
def dest_pg_id(self):
""" Get dest_pg_id value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destPgId` in VSD API.
"""
return self._dest_pg_id
@dest_pg_id.setter
def dest_pg_id(self, value):
""" Set dest_pg_id value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destPgId` in VSD API.
"""
self._dest_pg_id = value
@property
def dest_pg_type(self):
""" Get dest_pg_type value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destPgType` in VSD API.
"""
return self._dest_pg_type
@dest_pg_type.setter
def dest_pg_type(self, value):
""" Set dest_pg_type value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destPgType` in VSD API.
"""
self._dest_pg_type = value
@property
def destination_port(self):
""" Get destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
return self._destination_port
@destination_port.setter
def destination_port(self, value):
""" Set destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
self._destination_port = value
@property
def destination_type(self):
""" Get destination_type value.
Notes:
Network Type - either PolicyGroup or Network
This attribute is named `destinationType` in VSD API.
"""
return self._destination_type
@destination_type.setter
def destination_type(self, value):
""" Set destination_type value.
Notes:
Network Type - either PolicyGroup or Network
This attribute is named `destinationType` in VSD API.
"""
self._destination_type = value
@property
def destination_value(self):
""" Get destination_value value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destinationValue` in VSD API.
"""
return self._destination_value
@destination_value.setter
def destination_value(self, value):
""" Set destination_value value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destinationValue` in VSD API.
"""
self._destination_value = value
@property
def network_id(self):
""" Get network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
return self._network_id
@network_id.setter
def network_id(self, value):
""" Set network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
self._network_id = value
@property
def network_type(self):
""" Get network_type value.
Notes:
Type of the source network - VM_SUBNET or VM_ZONE or VM_DOMAIN or SUBNET or ZONE or ENTERPRISE_NETWORK or PUBLIC_NETWORK or ANY
This attribute is named `networkType` in VSD API.
"""
return self._network_type
@network_type.setter
def network_type(self, value):
""" Set network_type value.
Notes:
Type of the source network - VM_SUBNET or VM_ZONE or VM_DOMAIN or SUBNET or ZONE or ENTERPRISE_NETWORK or PUBLIC_NETWORK or ANY
This attribute is named `networkType` in VSD API.
"""
self._network_type = value
@property
def flow_logging_enabled(self):
""" Get flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
return self._flow_logging_enabled
@flow_logging_enabled.setter
def flow_logging_enabled(self, value):
""" Set flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
self._flow_logging_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location_id(self):
""" Get location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
return self._location_id
@location_id.setter
def location_id(self, value):
""" Set location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
self._location_id = value
@property
def location_type(self):
""" Get location_type value.
Notes:
Type of the location entity - ANY or SUBNET or ZONE or VPORTTAG
This attribute is named `locationType` in VSD API.
"""
return self._location_type
@location_type.setter
def location_type(self, value):
""" Set location_type value.
Notes:
Type of the location entity - ANY or SUBNET or ZONE or VPORTTAG
This attribute is named `locationType` in VSD API.
"""
self._location_type = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def source_pg_id(self):
""" Get source_pg_id value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourcePgId` in VSD API.
"""
return self._source_pg_id
@source_pg_id.setter
def source_pg_id(self, value):
""" Set source_pg_id value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourcePgId` in VSD API.
"""
self._source_pg_id = value
@property
def source_pg_type(self):
""" Get source_pg_type value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourcePgType` in VSD API.
"""
return self._source_pg_type
@source_pg_type.setter
def source_pg_type(self, value):
""" Set source_pg_type value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourcePgType` in VSD API.
"""
self._source_pg_type = value
@property
def source_port(self):
""" Get source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
return self._source_port
@source_port.setter
def source_port(self, value):
""" Set source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
self._source_port = value
@property
def source_type(self):
""" Get source_type value.
Notes:
Location Type - either PolicyGroup or Network
This attribute is named `sourceType` in VSD API.
"""
return self._source_type
@source_type.setter
def source_type(self, value):
""" Set source_type value.
Notes:
Location Type - either PolicyGroup or Network
This attribute is named `sourceType` in VSD API.
"""
self._source_type = value
@property
def source_value(self):
""" Get source_value value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourceValue` in VSD API.
"""
return self._source_value
@source_value.setter
def source_value(self, value):
""" Set source_value value.
Notes:
In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourceValue` in VSD API.
"""
self._source_value = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def protocol(self):
""" Get protocol value.
Notes:
Protocol number that must be matched
"""
return self._protocol
@protocol.setter
def protocol(self, value):
""" Set protocol value.
Notes:
Protocol number that must be matched
"""
self._protocol = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def stats_id(self):
""" Get stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
return self._stats_id
@stats_id.setter
def stats_id(self, value):
""" Set stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
self._stats_id = value
@property
def stats_logging_enabled(self):
""" Get stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
return self._stats_logging_enabled
@stats_logging_enabled.setter
def stats_logging_enabled(self, value):
""" Set stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
self._stats_logging_enabled = value
@property
def ether_type(self):
""" Get ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
return self._ether_type
@ether_type.setter
def ether_type(self, value):
""" Set ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
self._ether_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUDomainFIPAclTemplateEntry
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_DROP
var CONST_ACTION_FORWARD
var CONST_ACTION_REDIRECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_DESTINATION_TYPE_NETWORK
var CONST_DESTINATION_TYPE_NETWORKPOLICYGROUP
var CONST_DESTINATION_TYPE_POLICYGROUP
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_LOCATION_TYPE_ANY
var CONST_LOCATION_TYPE_POLICYGROUP
var CONST_LOCATION_TYPE_REDIRECTIONTARGET
var CONST_LOCATION_TYPE_SUBNET
var CONST_LOCATION_TYPE_VPORTTAG
var CONST_LOCATION_TYPE_ZONE
var CONST_NETWORK_TYPE_ANY
var CONST_NETWORK_TYPE_ENDPOINT_DOMAIN
var CONST_NETWORK_TYPE_ENDPOINT_SUBNET
var CONST_NETWORK_TYPE_ENDPOINT_ZONE
var CONST_NETWORK_TYPE_ENTERPRISE_NETWORK
var CONST_NETWORK_TYPE_INTERNET_POLICYGROUP
var CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP
var CONST_NETWORK_TYPE_POLICYGROUP
var CONST_NETWORK_TYPE_PUBLIC_NETWORK
var CONST_NETWORK_TYPE_SUBNET
var CONST_NETWORK_TYPE_ZONE
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_SOURCE_TYPE_NETWORK
var CONST_SOURCE_TYPE_NETWORKPOLICYGROUP
var CONST_SOURCE_TYPE_POLICYGROUP
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
var action_details
Get action_details value.
Notes: Type of action to be performed when a ACL match criteria succeeds
This attribute is named `actionDetails` in VSD API.
var address_override
Get address_override value.
Notes: Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the ACL entry
var dest_pg_id
Get dest_pg_id value.
Notes: In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destPgId` in VSD API.
var dest_pg_type
Get dest_pg_type value.
Notes: In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destPgType` in VSD API.
var destination_port
Get destination_port value.
Notes: The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
var destination_type
Get destination_type value.
Notes: Network Type - either PolicyGroup or Network
This attribute is named `destinationType` in VSD API.
var destination_value
Get destination_value value.
Notes: In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `destinationValue` in VSD API.
var dscp
Get dscp value.
Notes: DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var ether_type
Get ether_type value.
Notes: Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_logging_enabled
Get flow_logging_enabled value.
Notes: Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location_id
Get location_id value.
Notes: The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
var location_type
Get location_type value.
Notes: Type of the location entity - ANY or SUBNET or ZONE or VPORTTAG
This attribute is named `locationType` in VSD API.
var metadatas
var network_id
Get network_id value.
Notes: The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
var network_type
Get network_type value.
Notes: Type of the source network - VM_SUBNET or VM_ZONE or VM_DOMAIN or SUBNET or ZONE or ENTERPRISE_NETWORK or PUBLIC_NETWORK or ANY
This attribute is named `networkType` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy.
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var protocol
Get protocol value.
Notes: Protocol number that must be matched
var reflexive
Get reflexive value.
Notes: True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
var source_pg_id
Get source_pg_id value.
Notes: In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourcePgId` in VSD API.
var source_pg_type
Get source_pg_type value.
Notes: In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourcePgType` in VSD API.
var source_port
Get source_port value.
Notes: Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
var source_type
Get source_type value.
Notes: Location Type - either PolicyGroup or Network
This attribute is named `sourceType` in VSD API.
var source_value
Get source_value value.
Notes: In case of PG this will be its EVPNBGPCommunity String, incase of network it will be network cidr
This attribute is named `sourceValue` in VSD API.
var stats_id
Get stats_id value.
Notes: The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
var stats_logging_enabled
Get stats_logging_enabled value.
Notes: Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a DomainFIPAclTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> domainfipacltemplateentry = NUDomainFIPAclTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'DomainFIPAclTemplateEntry') >>> domainfipacltemplateentry = NUDomainFIPAclTemplateEntry(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a DomainFIPAclTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domainfipacltemplateentry = NUDomainFIPAclTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'DomainFIPAclTemplateEntry')
>>> domainfipacltemplateentry = NUDomainFIPAclTemplateEntry(data=my_dict)
"""
super(NUDomainFIPAclTemplateEntry, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._action_details = None
self._address_override = None
self._reflexive = None
self._description = None
self._dest_pg_id = None
self._dest_pg_type = None
self._destination_port = None
self._destination_type = None
self._destination_value = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_pg_id = None
self._source_pg_type = None
self._source_port = None
self._source_type = None
self._source_value = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="action_details", remote_name="actionDetails", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dest_pg_id", remote_name="destPgId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dest_pg_type", remote_name="destPgType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_type", remote_name="destinationType", attribute_type=str, is_required=False, is_unique=False, choices=[u'NETWORK', u'NETWORKPOLICYGROUP', u'POLICYGROUP'])
self.expose_attribute(local_name="destination_value", remote_name="destinationValue", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_pg_id", remote_name="sourcePgId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_pg_type", remote_name="sourcePgType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_type", remote_name="sourceType", attribute_type=str, is_required=False, is_unique=False, choices=[u'NETWORK', u'NETWORKPOLICYGROUP', u'POLICYGROUP'])
self.expose_attribute(local_name="source_value", remote_name="sourceValue", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUDomainTemplate
Represents a DomainTemplate in the VSD
Notes: Domains in VSD are created from domain templates. This object provides the definition of the DomainTemplate.
class NUDomainTemplate(NURESTObject):
""" Represents a DomainTemplate in the VSD
Notes:
Domains in VSD are created from domain templates. This object provides the definition of the DomainTemplate.
"""
__rest_name__ = "domaintemplate"
__resource_name__ = "domaintemplates"
## Constants
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_POLICY_CHANGE_STATUS_STARTED = "STARTED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_POLICY_CHANGE_STATUS_DISCARDED = "DISCARDED"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_MULTICAST_INHERITED = "INHERITED"
CONST_POLICY_CHANGE_STATUS_APPLIED = "APPLIED"
def __init__(self, **kwargs):
""" Initializes a DomainTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domaintemplate = NUDomainTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'DomainTemplate')
>>> domaintemplate = NUDomainTemplate(data=my_dict)
"""
super(NUDomainTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._encryption = None
self._entity_scope = None
self._policy_change_status = None
self._associated_multicast_channel_map_id = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.redirection_target_templates = NURedirectionTargetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domain_fip_acl_templates = NUDomainFIPAclTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ipacl_templates = NUFloatingIPACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_group_templates = NUPolicyGroupTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domains = NUDomainsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.zone_templates = NUZoneTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnet_templates = NUSubnetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The name of the domain template, that is unique within an enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the domain template, that is unique within an enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Domain template description provided by the user
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Domain template description provided by the user
"""
self._description = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether IPSEC is enabled. Possible values are ENABLED, DISABLED, .
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether IPSEC is enabled. Possible values are ENABLED, DISABLED, .
"""
self._encryption = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_change_status(self):
""" Get policy_change_status value.
Notes:
None
This attribute is named `policyChangeStatus` in VSD API.
"""
return self._policy_change_status
@policy_change_status.setter
def policy_change_status(self, value):
""" Set policy_change_status value.
Notes:
None
This attribute is named `policyChangeStatus` in VSD API.
"""
self._policy_change_status = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this domain template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this domain template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def multicast(self):
""" Get multicast value.
Notes:
Indicates multicast policy on domain.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
Indicates multicast policy on domain.
"""
self._multicast = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUDomainTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var CONST_POLICY_CHANGE_STATUS_APPLIED
var CONST_POLICY_CHANGE_STATUS_DISCARDED
var CONST_POLICY_CHANGE_STATUS_STARTED
var resource_name
var rest_name
Instance variables
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this domain template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Domain template description provided by the user
var domain_fip_acl_templates
var domains
var egress_acl_templates
var encryption
Get encryption value.
Notes: Determines whether IPSEC is enabled. Possible values are ENABLED, DISABLED, .
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var floating_ipacl_templates
var global_metadatas
var groups
var id
Get object id
var ingress_acl_templates
var ingress_adv_fwd_templates
var ingress_external_service_templates
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var multicast
Get multicast value.
Notes: Indicates multicast policy on domain.
var name
Get name value.
Notes: The name of the domain template, that is unique within an enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var policy_change_status
Get policy_change_status value.
Notes: None
This attribute is named `policyChangeStatus` in VSD API.
var policy_group_templates
var qoss
var redirection_target_templates
var subnet_templates
var zone_templates
Methods
def __init__(
self, **kwargs)
Initializes a DomainTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> domaintemplate = NUDomainTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'DomainTemplate') >>> domaintemplate = NUDomainTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a DomainTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> domaintemplate = NUDomainTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'DomainTemplate')
>>> domaintemplate = NUDomainTemplate(data=my_dict)
"""
super(NUDomainTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._encryption = None
self._entity_scope = None
self._policy_change_status = None
self._associated_multicast_channel_map_id = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.redirection_target_templates = NURedirectionTargetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domain_fip_acl_templates = NUDomainFIPAclTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ipacl_templates = NUFloatingIPACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_group_templates = NUPolicyGroupTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.domains = NUDomainsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.zone_templates = NUZoneTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnet_templates = NUSubnetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEgressACLEntryTemplate
Represents a EgressACLEntryTemplate in the VSD
Notes: Defines the template of Egress ACL Template entries
class NUEgressACLEntryTemplate(NURESTObject):
""" Represents a EgressACLEntryTemplate in the VSD
Notes:
Defines the template of Egress ACL Template entries
"""
__rest_name__ = "egressaclentrytemplate"
__resource_name__ = "egressaclentrytemplates"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ACTION_REDIRECT = "REDIRECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_NETWORK_TYPE_ENDPOINT_ZONE = "ENDPOINT_ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_LOCATION_TYPE_ANY = "ANY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_NETWORK_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_NETWORK_TYPE_ENDPOINT_DOMAIN = "ENDPOINT_DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_NETWORK_TYPE_ANY = "ANY"
CONST_LOCATION_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_LOCATION_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_LOCATION_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_LOCATION_TYPE_REDIRECTIONTARGET = "REDIRECTIONTARGET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ACTION_DROP = "DROP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_NETWORK_TYPE_INTERNET_POLICYGROUP = "INTERNET_POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_LOCATION_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_NETWORK_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ACTION_FORWARD = "FORWARD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_NETWORK_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_NETWORK_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_NETWORK_TYPE_ENDPOINT_SUBNET = "ENDPOINT_SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
def __init__(self, **kwargs):
""" Initializes a EgressACLEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> egressaclentrytemplate = NUEgressACLEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'EgressACLEntryTemplate')
>>> egressaclentrytemplate = NUEgressACLEntryTemplate(data=my_dict)
"""
super(NUEgressACLEntryTemplate, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._reflexive = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def action(self):
""" Get action value.
Notes:
The action of the ACL entry.
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The action of the ACL entry.
"""
self._action = value
@property
def address_override(self):
""" Get address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
return self._address_override
@address_override.setter
def address_override(self, value):
""" Set address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
self._address_override = value
@property
def reflexive(self):
""" Get reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
return self._reflexive
@reflexive.setter
def reflexive(self, value):
""" Set reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
self._reflexive = value
@property
def description(self):
""" Get description value.
Notes:
Description of the ACL entry
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the ACL entry
"""
self._description = value
@property
def destination_port(self):
""" Get destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
return self._destination_port
@destination_port.setter
def destination_port(self, value):
""" Set destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
self._destination_port = value
@property
def network_id(self):
""" Get network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
return self._network_id
@network_id.setter
def network_id(self, value):
""" Set network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
self._network_id = value
@property
def network_type(self):
""" Get network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
return self._network_type
@network_type.setter
def network_type(self, value):
""" Set network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
self._network_type = value
@property
def flow_logging_enabled(self):
""" Get flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
return self._flow_logging_enabled
@flow_logging_enabled.setter
def flow_logging_enabled(self, value):
""" Set flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
self._flow_logging_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location_id(self):
""" Get location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
return self._location_id
@location_id.setter
def location_id(self, value):
""" Set location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
self._location_id = value
@property
def location_type(self):
""" Get location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
return self._location_type
@location_type.setter
def location_type(self, value):
""" Set location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
self._location_type = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy. Possible values are DRAFT, LIVE, .
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy. Possible values are DRAFT, LIVE, .
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def source_port(self):
""" Get source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
return self._source_port
@source_port.setter
def source_port(self, value):
""" Set source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
self._source_port = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def protocol(self):
""" Get protocol value.
Notes:
Protocol number that must be matched
"""
return self._protocol
@protocol.setter
def protocol(self, value):
""" Set protocol value.
Notes:
Protocol number that must be matched
"""
self._protocol = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def stats_id(self):
""" Get stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
return self._stats_id
@stats_id.setter
def stats_id(self, value):
""" Set stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
self._stats_id = value
@property
def stats_logging_enabled(self):
""" Get stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
return self._stats_logging_enabled
@stats_logging_enabled.setter
def stats_logging_enabled(self, value):
""" Set stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
self._stats_logging_enabled = value
@property
def ether_type(self):
""" Get ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
return self._ether_type
@ether_type.setter
def ether_type(self, value):
""" Set ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
self._ether_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
Ancestors (in MRO)
- NUEgressACLEntryTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_DROP
var CONST_ACTION_FORWARD
var CONST_ACTION_REDIRECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_LOCATION_TYPE_ANY
var CONST_LOCATION_TYPE_POLICYGROUP
var CONST_LOCATION_TYPE_REDIRECTIONTARGET
var CONST_LOCATION_TYPE_SUBNET
var CONST_LOCATION_TYPE_VPORTTAG
var CONST_LOCATION_TYPE_ZONE
var CONST_NETWORK_TYPE_ANY
var CONST_NETWORK_TYPE_ENDPOINT_DOMAIN
var CONST_NETWORK_TYPE_ENDPOINT_SUBNET
var CONST_NETWORK_TYPE_ENDPOINT_ZONE
var CONST_NETWORK_TYPE_ENTERPRISE_NETWORK
var CONST_NETWORK_TYPE_INTERNET_POLICYGROUP
var CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP
var CONST_NETWORK_TYPE_POLICYGROUP
var CONST_NETWORK_TYPE_PUBLIC_NETWORK
var CONST_NETWORK_TYPE_SUBNET
var CONST_NETWORK_TYPE_ZONE
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The action of the ACL entry.
var address_override
Get address_override value.
Notes: Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the ACL entry
var destination_port
Get destination_port value.
Notes: The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
var dscp
Get dscp value.
Notes: DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var ether_type
Get ether_type value.
Notes: Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_logging_enabled
Get flow_logging_enabled value.
Notes: Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location_id
Get location_id value.
Notes: The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
var location_type
Get location_type value.
Notes: Type of the location entity.
This attribute is named `locationType` in VSD API.
var metadatas
var network_id
Get network_id value.
Notes: The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
var network_type
Get network_type value.
Notes: Type of the source network.
This attribute is named `networkType` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy. Possible values are DRAFT, LIVE, .
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var protocol
Get protocol value.
Notes: Protocol number that must be matched
var reflexive
Get reflexive value.
Notes: True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
var source_port
Get source_port value.
Notes: Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
var statistics
var stats_id
Get stats_id value.
Notes: The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
var stats_logging_enabled
Get stats_logging_enabled value.
Notes: Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a EgressACLEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> egressaclentrytemplate = NUEgressACLEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'EgressACLEntryTemplate') >>> egressaclentrytemplate = NUEgressACLEntryTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EgressACLEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> egressaclentrytemplate = NUEgressACLEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'EgressACLEntryTemplate')
>>> egressaclentrytemplate = NUEgressACLEntryTemplate(data=my_dict)
"""
super(NUEgressACLEntryTemplate, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._reflexive = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEgressACLTemplate
Represents a EgressACLTemplate in the VSD
Notes: Defines the template for an Egress ACL.
class NUEgressACLTemplate(NURESTObject):
""" Represents a EgressACLTemplate in the VSD
Notes:
Defines the template for an Egress ACL.
"""
__rest_name__ = "egressacltemplate"
__resource_name__ = "egressacltemplates"
## Constants
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PRIORITY_TYPE_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PRIORITY_TYPE_TOP = "TOP"
CONST_PRIORITY_TYPE_BOTTOM = "BOTTOM"
def __init__(self, **kwargs):
""" Initializes a EgressACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> egressacltemplate = NUEgressACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'EgressACLTemplate')
>>> egressacltemplate = NUEgressACLTemplate(data=my_dict)
"""
super(NUEgressACLTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._default_install_acl_implicit_rules = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_install_acl_implicit_rules", remote_name="defaultInstallACLImplicitRules", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The name of the entity
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the entity
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def active(self):
""" Get active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
self._active = value
@property
def default_allow_ip(self):
""" Get default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
return self._default_allow_ip
@default_allow_ip.setter
def default_allow_ip(self, value):
""" Set default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
self._default_allow_ip = value
@property
def default_allow_non_ip(self):
""" Get default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
return self._default_allow_non_ip
@default_allow_non_ip.setter
def default_allow_non_ip(self, value):
""" Set default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
self._default_allow_non_ip = value
@property
def default_install_acl_implicit_rules(self):
""" Get default_install_acl_implicit_rules value.
Notes:
If enabled, implicit rule will allow intra domain traffic by default
This attribute is named `defaultInstallACLImplicitRules` in VSD API.
"""
return self._default_install_acl_implicit_rules
@default_install_acl_implicit_rules.setter
def default_install_acl_implicit_rules(self, value):
""" Set default_install_acl_implicit_rules value.
Notes:
If enabled, implicit rule will allow intra domain traffic by default
This attribute is named `defaultInstallACLImplicitRules` in VSD API.
"""
self._default_install_acl_implicit_rules = value
@property
def description(self):
""" Get description value.
Notes:
A description of the entity
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the entity
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def priority_type(self):
""" Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
return self._priority_type
@priority_type.setter
def priority_type(self, value):
""" Set priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
self._priority_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEgressACLTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_PRIORITY_TYPE_BOTTOM
var CONST_PRIORITY_TYPE_NONE
var CONST_PRIORITY_TYPE_TOP
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: If enabled, it means that this ACL or QOS entry is active
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var default_allow_ip
Get default_allow_ip value.
Notes: If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
var default_allow_non_ip
Get default_allow_non_ip value.
Notes: If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
var default_install_acl_implicit_rules
Get default_install_acl_implicit_rules value.
Notes: If enabled, implicit rule will allow intra domain traffic by default
This attribute is named `defaultInstallACLImplicitRules` in VSD API.
var description
Get description value.
Notes: A description of the entity
var egress_acl_entry_templates
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: The name of the entity
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var priority_type
Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
var vms
Methods
def __init__(
self, **kwargs)
Initializes a EgressACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> egressacltemplate = NUEgressACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'EgressACLTemplate') >>> egressacltemplate = NUEgressACLTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EgressACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> egressacltemplate = NUEgressACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'EgressACLTemplate')
>>> egressacltemplate = NUEgressACLTemplate(data=my_dict)
"""
super(NUEgressACLTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._default_install_acl_implicit_rules = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_install_acl_implicit_rules", remote_name="defaultInstallACLImplicitRules", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEgressQOSPolicy
Represents a EgressQOSPolicy in the VSD
Notes: The object manipulates Egress QoS parameters attached to a Access Port / VLAN or Network port.
class NUEgressQOSPolicy(NURESTObject):
""" Represents a EgressQOSPolicy in the VSD
Notes:
The object manipulates Egress QoS parameters attached to a Access Port / VLAN or Network port.
"""
__rest_name__ = "egressqospolicy"
__resource_name__ = "egressqospolicies"
## Constants
CONST_QUEUE2_FORWARDING_CLASSES_H = "H"
CONST_QUEUE2_FORWARDING_CLASSES_NONE = "NONE"
CONST_QUEUE2_FORWARDING_CLASSES_A = "A"
CONST_QUEUE2_FORWARDING_CLASSES_B = "B"
CONST_QUEUE2_FORWARDING_CLASSES_C = "C"
CONST_QUEUE2_FORWARDING_CLASSES_D = "D"
CONST_QUEUE2_FORWARDING_CLASSES_E = "E"
CONST_QUEUE2_FORWARDING_CLASSES_F = "F"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_QUEUE4_FORWARDING_CLASSES_NONE = "NONE"
CONST_QUEUE1_FORWARDING_CLASSES_NONE = "NONE"
CONST_QUEUE3_FORWARDING_CLASSES_H = "H"
CONST_QUEUE3_FORWARDING_CLASSES_C = "C"
CONST_QUEUE3_FORWARDING_CLASSES_B = "B"
CONST_QUEUE3_FORWARDING_CLASSES_A = "A"
CONST_QUEUE3_FORWARDING_CLASSES_G = "G"
CONST_QUEUE3_FORWARDING_CLASSES_F = "F"
CONST_QUEUE3_FORWARDING_CLASSES_E = "E"
CONST_QUEUE3_FORWARDING_CLASSES_D = "D"
CONST_QUEUE1_FORWARDING_CLASSES_A = "A"
CONST_QUEUE1_FORWARDING_CLASSES_C = "C"
CONST_QUEUE1_FORWARDING_CLASSES_B = "B"
CONST_QUEUE1_FORWARDING_CLASSES_E = "E"
CONST_QUEUE1_FORWARDING_CLASSES_D = "D"
CONST_QUEUE1_FORWARDING_CLASSES_G = "G"
CONST_QUEUE1_FORWARDING_CLASSES_F = "F"
CONST_QUEUE1_FORWARDING_CLASSES_H = "H"
CONST_QUEUE4_FORWARDING_CLASSES_B = "B"
CONST_QUEUE4_FORWARDING_CLASSES_C = "C"
CONST_QUEUE4_FORWARDING_CLASSES_A = "A"
CONST_QUEUE4_FORWARDING_CLASSES_F = "F"
CONST_QUEUE4_FORWARDING_CLASSES_G = "G"
CONST_QUEUE4_FORWARDING_CLASSES_D = "D"
CONST_QUEUE4_FORWARDING_CLASSES_E = "E"
CONST_QUEUE4_FORWARDING_CLASSES_H = "H"
CONST_QUEUE2_FORWARDING_CLASSES_G = "G"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_QUEUE3_FORWARDING_CLASSES_NONE = "NONE"
def __init__(self, **kwargs):
""" Initializes a EgressQOSPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> egressqospolicy = NUEgressQOSPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'EgressQOSPolicy')
>>> egressqospolicy = NUEgressQOSPolicy(data=my_dict)
"""
super(NUEgressQOSPolicy, self).__init__()
# Read/Write Attributes
self._name = None
self._parent_queue_associated_rate_limiter_id = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._assoc_egress_qos_id = None
self._queue1_associated_rate_limiter_id = None
self._queue1_forwarding_classes = None
self._queue2_associated_rate_limiter_id = None
self._queue2_forwarding_classes = None
self._queue3_associated_rate_limiter_id = None
self._queue3_forwarding_classes = None
self._queue4_associated_rate_limiter_id = None
self._queue4_forwarding_classes = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="parent_queue_associated_rate_limiter_id", remote_name="parentQueueAssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="assoc_egress_qos_id", remote_name="assocEgressQosId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue1_associated_rate_limiter_id", remote_name="queue1AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue1_forwarding_classes", remote_name="queue1ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="queue2_associated_rate_limiter_id", remote_name="queue2AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue2_forwarding_classes", remote_name="queue2ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="queue3_associated_rate_limiter_id", remote_name="queue3AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue3_forwarding_classes", remote_name="queue3ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="queue4_associated_rate_limiter_id", remote_name="queue4AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue4_forwarding_classes", remote_name="queue4ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
A unique name of the QoS object
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
A unique name of the QoS object
"""
self._name = value
@property
def parent_queue_associated_rate_limiter_id(self):
""" Get parent_queue_associated_rate_limiter_id value.
Notes:
ID of the parent rate limiter associated with this Egress QOS policy.
This attribute is named `parentQueueAssociatedRateLimiterID` in VSD API.
"""
return self._parent_queue_associated_rate_limiter_id
@parent_queue_associated_rate_limiter_id.setter
def parent_queue_associated_rate_limiter_id(self, value):
""" Set parent_queue_associated_rate_limiter_id value.
Notes:
ID of the parent rate limiter associated with this Egress QOS policy.
This attribute is named `parentQueueAssociatedRateLimiterID` in VSD API.
"""
self._parent_queue_associated_rate_limiter_id = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the QoS object
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the QoS object
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def assoc_egress_qos_id(self):
""" Get assoc_egress_qos_id value.
Notes:
ID of object associated with this QoS object
This attribute is named `assocEgressQosId` in VSD API.
"""
return self._assoc_egress_qos_id
@assoc_egress_qos_id.setter
def assoc_egress_qos_id(self, value):
""" Set assoc_egress_qos_id value.
Notes:
ID of object associated with this QoS object
This attribute is named `assocEgressQosId` in VSD API.
"""
self._assoc_egress_qos_id = value
@property
def queue1_associated_rate_limiter_id(self):
""" Get queue1_associated_rate_limiter_id value.
Notes:
ID of the queue1 rate limiter associated with this Egress QOS policy.
This attribute is named `queue1AssociatedRateLimiterID` in VSD API.
"""
return self._queue1_associated_rate_limiter_id
@queue1_associated_rate_limiter_id.setter
def queue1_associated_rate_limiter_id(self, value):
""" Set queue1_associated_rate_limiter_id value.
Notes:
ID of the queue1 rate limiter associated with this Egress QOS policy.
This attribute is named `queue1AssociatedRateLimiterID` in VSD API.
"""
self._queue1_associated_rate_limiter_id = value
@property
def queue1_forwarding_classes(self):
""" Get queue1_forwarding_classes value.
Notes:
Queue1 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue1ForwardingClasses` in VSD API.
"""
return self._queue1_forwarding_classes
@queue1_forwarding_classes.setter
def queue1_forwarding_classes(self, value):
""" Set queue1_forwarding_classes value.
Notes:
Queue1 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue1ForwardingClasses` in VSD API.
"""
self._queue1_forwarding_classes = value
@property
def queue2_associated_rate_limiter_id(self):
""" Get queue2_associated_rate_limiter_id value.
Notes:
ID of the queue2 rate limiter associated with this Egress QOS policy.
This attribute is named `queue2AssociatedRateLimiterID` in VSD API.
"""
return self._queue2_associated_rate_limiter_id
@queue2_associated_rate_limiter_id.setter
def queue2_associated_rate_limiter_id(self, value):
""" Set queue2_associated_rate_limiter_id value.
Notes:
ID of the queue2 rate limiter associated with this Egress QOS policy.
This attribute is named `queue2AssociatedRateLimiterID` in VSD API.
"""
self._queue2_associated_rate_limiter_id = value
@property
def queue2_forwarding_classes(self):
""" Get queue2_forwarding_classes value.
Notes:
Queue2 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue2ForwardingClasses` in VSD API.
"""
return self._queue2_forwarding_classes
@queue2_forwarding_classes.setter
def queue2_forwarding_classes(self, value):
""" Set queue2_forwarding_classes value.
Notes:
Queue2 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue2ForwardingClasses` in VSD API.
"""
self._queue2_forwarding_classes = value
@property
def queue3_associated_rate_limiter_id(self):
""" Get queue3_associated_rate_limiter_id value.
Notes:
ID of the queue3 rate limiter associated with this Egress QOS policy.
This attribute is named `queue3AssociatedRateLimiterID` in VSD API.
"""
return self._queue3_associated_rate_limiter_id
@queue3_associated_rate_limiter_id.setter
def queue3_associated_rate_limiter_id(self, value):
""" Set queue3_associated_rate_limiter_id value.
Notes:
ID of the queue3 rate limiter associated with this Egress QOS policy.
This attribute is named `queue3AssociatedRateLimiterID` in VSD API.
"""
self._queue3_associated_rate_limiter_id = value
@property
def queue3_forwarding_classes(self):
""" Get queue3_forwarding_classes value.
Notes:
Queue3 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue3ForwardingClasses` in VSD API.
"""
return self._queue3_forwarding_classes
@queue3_forwarding_classes.setter
def queue3_forwarding_classes(self, value):
""" Set queue3_forwarding_classes value.
Notes:
Queue3 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue3ForwardingClasses` in VSD API.
"""
self._queue3_forwarding_classes = value
@property
def queue4_associated_rate_limiter_id(self):
""" Get queue4_associated_rate_limiter_id value.
Notes:
ID of the queue4 rate limiter associated with this Egress QOS policy.
This attribute is named `queue4AssociatedRateLimiterID` in VSD API.
"""
return self._queue4_associated_rate_limiter_id
@queue4_associated_rate_limiter_id.setter
def queue4_associated_rate_limiter_id(self, value):
""" Set queue4_associated_rate_limiter_id value.
Notes:
ID of the queue4 rate limiter associated with this Egress QOS policy.
This attribute is named `queue4AssociatedRateLimiterID` in VSD API.
"""
self._queue4_associated_rate_limiter_id = value
@property
def queue4_forwarding_classes(self):
""" Get queue4_forwarding_classes value.
Notes:
Queue4 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue4ForwardingClasses` in VSD API.
"""
return self._queue4_forwarding_classes
@queue4_forwarding_classes.setter
def queue4_forwarding_classes(self, value):
""" Set queue4_forwarding_classes value.
Notes:
Queue4 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue4ForwardingClasses` in VSD API.
"""
self._queue4_forwarding_classes = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEgressQOSPolicy
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_QUEUE1_FORWARDING_CLASSES_A
var CONST_QUEUE1_FORWARDING_CLASSES_B
var CONST_QUEUE1_FORWARDING_CLASSES_C
var CONST_QUEUE1_FORWARDING_CLASSES_D
var CONST_QUEUE1_FORWARDING_CLASSES_E
var CONST_QUEUE1_FORWARDING_CLASSES_F
var CONST_QUEUE1_FORWARDING_CLASSES_G
var CONST_QUEUE1_FORWARDING_CLASSES_H
var CONST_QUEUE1_FORWARDING_CLASSES_NONE
var CONST_QUEUE2_FORWARDING_CLASSES_A
var CONST_QUEUE2_FORWARDING_CLASSES_B
var CONST_QUEUE2_FORWARDING_CLASSES_C
var CONST_QUEUE2_FORWARDING_CLASSES_D
var CONST_QUEUE2_FORWARDING_CLASSES_E
var CONST_QUEUE2_FORWARDING_CLASSES_F
var CONST_QUEUE2_FORWARDING_CLASSES_G
var CONST_QUEUE2_FORWARDING_CLASSES_H
var CONST_QUEUE2_FORWARDING_CLASSES_NONE
var CONST_QUEUE3_FORWARDING_CLASSES_A
var CONST_QUEUE3_FORWARDING_CLASSES_B
var CONST_QUEUE3_FORWARDING_CLASSES_C
var CONST_QUEUE3_FORWARDING_CLASSES_D
var CONST_QUEUE3_FORWARDING_CLASSES_E
var CONST_QUEUE3_FORWARDING_CLASSES_F
var CONST_QUEUE3_FORWARDING_CLASSES_G
var CONST_QUEUE3_FORWARDING_CLASSES_H
var CONST_QUEUE3_FORWARDING_CLASSES_NONE
var CONST_QUEUE4_FORWARDING_CLASSES_A
var CONST_QUEUE4_FORWARDING_CLASSES_B
var CONST_QUEUE4_FORWARDING_CLASSES_C
var CONST_QUEUE4_FORWARDING_CLASSES_D
var CONST_QUEUE4_FORWARDING_CLASSES_E
var CONST_QUEUE4_FORWARDING_CLASSES_F
var CONST_QUEUE4_FORWARDING_CLASSES_G
var CONST_QUEUE4_FORWARDING_CLASSES_H
var CONST_QUEUE4_FORWARDING_CLASSES_NONE
var resource_name
var rest_name
Instance variables
var assoc_egress_qos_id
Get assoc_egress_qos_id value.
Notes: ID of object associated with this QoS object
This attribute is named `assocEgressQosId` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the QoS object
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: A unique name of the QoS object
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_queue_associated_rate_limiter_id
Get parent_queue_associated_rate_limiter_id value.
Notes: ID of the parent rate limiter associated with this Egress QOS policy.
This attribute is named `parentQueueAssociatedRateLimiterID` in VSD API.
var parent_type
Get parent type
var queue1_associated_rate_limiter_id
Get queue1_associated_rate_limiter_id value.
Notes: ID of the queue1 rate limiter associated with this Egress QOS policy.
This attribute is named `queue1AssociatedRateLimiterID` in VSD API.
var queue1_forwarding_classes
Get queue1_forwarding_classes value.
Notes: Queue1 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue1ForwardingClasses` in VSD API.
var queue2_associated_rate_limiter_id
Get queue2_associated_rate_limiter_id value.
Notes: ID of the queue2 rate limiter associated with this Egress QOS policy.
This attribute is named `queue2AssociatedRateLimiterID` in VSD API.
var queue2_forwarding_classes
Get queue2_forwarding_classes value.
Notes: Queue2 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue2ForwardingClasses` in VSD API.
var queue3_associated_rate_limiter_id
Get queue3_associated_rate_limiter_id value.
Notes: ID of the queue3 rate limiter associated with this Egress QOS policy.
This attribute is named `queue3AssociatedRateLimiterID` in VSD API.
var queue3_forwarding_classes
Get queue3_forwarding_classes value.
Notes: Queue3 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue3ForwardingClasses` in VSD API.
var queue4_associated_rate_limiter_id
Get queue4_associated_rate_limiter_id value.
Notes: ID of the queue4 rate limiter associated with this Egress QOS policy.
This attribute is named `queue4AssociatedRateLimiterID` in VSD API.
var queue4_forwarding_classes
Get queue4_forwarding_classes value.
Notes: Queue4 Forwarding Classes for this Egress QOS Policy Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `queue4ForwardingClasses` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a EgressQOSPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> egressqospolicy = NUEgressQOSPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'EgressQOSPolicy') >>> egressqospolicy = NUEgressQOSPolicy(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EgressQOSPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> egressqospolicy = NUEgressQOSPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'EgressQOSPolicy')
>>> egressqospolicy = NUEgressQOSPolicy(data=my_dict)
"""
super(NUEgressQOSPolicy, self).__init__()
# Read/Write Attributes
self._name = None
self._parent_queue_associated_rate_limiter_id = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._assoc_egress_qos_id = None
self._queue1_associated_rate_limiter_id = None
self._queue1_forwarding_classes = None
self._queue2_associated_rate_limiter_id = None
self._queue2_forwarding_classes = None
self._queue3_associated_rate_limiter_id = None
self._queue3_forwarding_classes = None
self._queue4_associated_rate_limiter_id = None
self._queue4_forwarding_classes = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="parent_queue_associated_rate_limiter_id", remote_name="parentQueueAssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="assoc_egress_qos_id", remote_name="assocEgressQosId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue1_associated_rate_limiter_id", remote_name="queue1AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue1_forwarding_classes", remote_name="queue1ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="queue2_associated_rate_limiter_id", remote_name="queue2AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue2_forwarding_classes", remote_name="queue2ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="queue3_associated_rate_limiter_id", remote_name="queue3AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue3_forwarding_classes", remote_name="queue3ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="queue4_associated_rate_limiter_id", remote_name="queue4AssociatedRateLimiterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="queue4_forwarding_classes", remote_name="queue4ForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEndPoint
Represents a EndPoint in the VSD
Notes: Representation of End Point
class NUEndPoint(NURESTObject):
""" Represents a EndPoint in the VSD
Notes:
Representation of End Point
"""
__rest_name__ = "endpoint"
__resource_name__ = "endpoints"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a EndPoint instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> endpoint = NUEndPoint(id=u'xxxx-xxx-xxx-xxx', name=u'EndPoint')
>>> endpoint = NUEndPoint(data=my_dict)
"""
super(NUEndPoint, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
unique name of the External Service.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
unique name of the External Service.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the External Service.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the External Service.
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEndPoint
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the External Service.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: unique name of the External Service.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a EndPoint instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> endpoint = NUEndPoint(id=u'xxxx-xxx-xxx-xxx', name=u'EndPoint') >>> endpoint = NUEndPoint(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EndPoint instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> endpoint = NUEndPoint(id=u'xxxx-xxx-xxx-xxx', name=u'EndPoint')
>>> endpoint = NUEndPoint(data=my_dict)
"""
super(NUEndPoint, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEnterpriseNetwork
Represents a EnterpriseNetwork in the VSD
Notes: Administrators of an enterprise can define macros that are set of IP addresses that identify enterprise networks. These macros can be used in the ACL definitions by network designers and other users to identify access restrictions towards specific enterprise networks.
class NUEnterpriseNetwork(NURESTObject):
""" Represents a EnterpriseNetwork in the VSD
Notes:
Administrators of an enterprise can define macros that are set of IP addresses that identify enterprise networks. These macros can be used in the ACL definitions by network designers and other users to identify access restrictions towards specific enterprise networks.
"""
__rest_name__ = "enterprisenetwork"
__resource_name__ = "enterprisenetworks"
## Constants
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a EnterpriseNetwork instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisenetwork = NUEnterpriseNetwork(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseNetwork')
>>> enterprisenetwork = NUEnterpriseNetwork(data=my_dict)
"""
super(NUEnterpriseNetwork, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._address = None
self._netmask = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.network_macro_groups = NUNetworkMacroGroupsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def name(self):
""" Get name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
self._address = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet defined
"""
self._netmask = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEnterpriseNetwork
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the subnet defined
var network_macro_groups
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a EnterpriseNetwork instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> enterprisenetwork = NUEnterpriseNetwork(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseNetwork') >>> enterprisenetwork = NUEnterpriseNetwork(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EnterpriseNetwork instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisenetwork = NUEnterpriseNetwork(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseNetwork')
>>> enterprisenetwork = NUEnterpriseNetwork(data=my_dict)
"""
super(NUEnterpriseNetwork, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._address = None
self._netmask = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.network_macro_groups = NUNetworkMacroGroupsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEnterprisePermission
Represents a EnterprisePermission in the VSD
Notes: Represents Enterprise Permission for a CSP entity.
class NUEnterprisePermission(NURESTObject):
""" Represents a EnterprisePermission in the VSD
Notes:
Represents Enterprise Permission for a CSP entity.
"""
__rest_name__ = "enterprisepermission"
__resource_name__ = "enterprisepermissions"
## Constants
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
def __init__(self, **kwargs):
""" Initializes a EnterprisePermission instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisepermission = NUEnterprisePermission(id=u'xxxx-xxx-xxx-xxx', name=u'EnterprisePermission')
>>> enterprisepermission = NUEnterprisePermission(data=my_dict)
"""
super(NUEnterprisePermission, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._permitted_entity_description = None
self._permitted_entity_id = None
self._permitted_entity_name = None
self._permitted_entity_type = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=True, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="permitted_entity_description", remote_name="permittedEntityDescription", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_id", remote_name="permittedEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_name", remote_name="permittedEntityName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_type", remote_name="permittedEntityType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Permission
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Permission
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def permitted_entity_description(self):
""" Get permitted_entity_description value.
Notes:
Description for the permittedEntity
This attribute is named `permittedEntityDescription` in VSD API.
"""
return self._permitted_entity_description
@permitted_entity_description.setter
def permitted_entity_description(self, value):
""" Set permitted_entity_description value.
Notes:
Description for the permittedEntity
This attribute is named `permittedEntityDescription` in VSD API.
"""
self._permitted_entity_description = value
@property
def permitted_entity_id(self):
""" Get permitted_entity_id value.
Notes:
The enterprise permitted to use/extend this Gateway
This attribute is named `permittedEntityID` in VSD API.
"""
return self._permitted_entity_id
@permitted_entity_id.setter
def permitted_entity_id(self, value):
""" Set permitted_entity_id value.
Notes:
The enterprise permitted to use/extend this Gateway
This attribute is named `permittedEntityID` in VSD API.
"""
self._permitted_entity_id = value
@property
def permitted_entity_name(self):
""" Get permitted_entity_name value.
Notes:
Name of the entity for which we have given permission.
This attribute is named `permittedEntityName` in VSD API.
"""
return self._permitted_entity_name
@permitted_entity_name.setter
def permitted_entity_name(self, value):
""" Set permitted_entity_name value.
Notes:
Name of the entity for which we have given permission.
This attribute is named `permittedEntityName` in VSD API.
"""
self._permitted_entity_name = value
@property
def permitted_entity_type(self):
""" Get permitted_entity_type value.
Notes:
Type of the entity for which we have given permission.
This attribute is named `permittedEntityType` in VSD API.
"""
return self._permitted_entity_type
@permitted_entity_type.setter
def permitted_entity_type(self, value):
""" Set permitted_entity_type value.
Notes:
Type of the entity for which we have given permission.
This attribute is named `permittedEntityType` in VSD API.
"""
self._permitted_entity_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEnterprisePermission
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Permission
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permitted_action
Get permitted_action value.
Notes: The permitted action.
This attribute is named `permittedAction` in VSD API.
var permitted_entity_description
Get permitted_entity_description value.
Notes: Description for the permittedEntity
This attribute is named `permittedEntityDescription` in VSD API.
var permitted_entity_id
Get permitted_entity_id value.
Notes: The enterprise permitted to use/extend this Gateway
This attribute is named `permittedEntityID` in VSD API.
var permitted_entity_name
Get permitted_entity_name value.
Notes: Name of the entity for which we have given permission.
This attribute is named `permittedEntityName` in VSD API.
var permitted_entity_type
Get permitted_entity_type value.
Notes: Type of the entity for which we have given permission.
This attribute is named `permittedEntityType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a EnterprisePermission instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> enterprisepermission = NUEnterprisePermission(id=u'xxxx-xxx-xxx-xxx', name=u'EnterprisePermission') >>> enterprisepermission = NUEnterprisePermission(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EnterprisePermission instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisepermission = NUEnterprisePermission(id=u'xxxx-xxx-xxx-xxx', name=u'EnterprisePermission')
>>> enterprisepermission = NUEnterprisePermission(data=my_dict)
"""
super(NUEnterprisePermission, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._permitted_entity_description = None
self._permitted_entity_id = None
self._permitted_entity_name = None
self._permitted_entity_type = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=True, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="permitted_entity_description", remote_name="permittedEntityDescription", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_id", remote_name="permittedEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_name", remote_name="permittedEntityName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_type", remote_name="permittedEntityType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEnterpriseProfile
Represents a EnterpriseProfile in the VSD
Notes: Enterprise profile, used to store an enterprise's policies, quota etc.
class NUEnterpriseProfile(NURESTObject):
""" Represents a EnterpriseProfile in the VSD
Notes:
Enterprise profile, used to store an enterprise's policies, quota etc.
"""
__rest_name__ = "enterpriseprofile"
__resource_name__ = "enterpriseprofiles"
## Constants
CONST_ENCRYPTION_MANAGEMENT_MODE_MANAGED = "MANAGED"
CONST_ALLOWED_FORWARDING_CLASSES_NONE = "NONE"
CONST_ENCRYPTION_MANAGEMENT_MODE_DISABLED = "DISABLED"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ALLOWED_FORWARDING_CLASSES_D = "D"
CONST_ALLOWED_FORWARDING_CLASSES_E = "E"
CONST_ALLOWED_FORWARDING_CLASSES_F = "F"
CONST_ALLOWED_FORWARDING_CLASSES_G = "G"
CONST_ALLOWED_FORWARDING_CLASSES_A = "A"
CONST_ALLOWED_FORWARDING_CLASSES_B = "B"
CONST_ALLOWED_FORWARDING_CLASSES_C = "C"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ALLOWED_FORWARDING_CLASSES_H = "H"
def __init__(self, **kwargs):
""" Initializes a EnterpriseProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterpriseprofile = NUEnterpriseProfile(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseProfile')
>>> enterpriseprofile = NUEnterpriseProfile(data=my_dict)
"""
super(NUEnterpriseProfile, self).__init__()
# Read/Write Attributes
self._dhcp_lease_interval = None
self._name = None
self._last_updated_by = None
self._receive_multi_cast_list_id = None
self._send_multi_cast_list_id = None
self._description = None
self._allow_advanced_qos_configuration = None
self._allow_gateway_management = None
self._allow_trusted_forwarding_class = None
self._allowed_forwarding_classes = None
self._floating_ips_quota = None
self._encryption_management_mode = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="dhcp_lease_interval", remote_name="DHCPLeaseInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="receive_multi_cast_list_id", remote_name="receiveMultiCastListID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="send_multi_cast_list_id", remote_name="sendMultiCastListID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_advanced_qos_configuration", remote_name="allowAdvancedQOSConfiguration", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_gateway_management", remote_name="allowGatewayManagement", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_trusted_forwarding_class", remote_name="allowTrustedForwardingClass", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_forwarding_classes", remote_name="allowedForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="floating_ips_quota", remote_name="floatingIPsQuota", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption_management_mode", remote_name="encryptionManagementMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'MANAGED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprises = NUEnterprisesFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.multi_cast_lists = NUMultiCastListsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.external_services = NUExternalServicesFetcher.fetcher_with_object(parent_object=self, relationship="member")
self._compute_args(**kwargs)
# Properties
@property
def dhcp_lease_interval(self):
""" Get dhcp_lease_interval value.
Notes:
DHCP Lease Interval (in hours) to be used by an enterprise.
This attribute is named `DHCPLeaseInterval` in VSD API.
"""
return self._dhcp_lease_interval
@dhcp_lease_interval.setter
def dhcp_lease_interval(self, value):
""" Set dhcp_lease_interval value.
Notes:
DHCP Lease Interval (in hours) to be used by an enterprise.
This attribute is named `DHCPLeaseInterval` in VSD API.
"""
self._dhcp_lease_interval = value
@property
def name(self):
""" Get name value.
Notes:
The unique name of the enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The unique name of the enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def receive_multi_cast_list_id(self):
""" Get receive_multi_cast_list_id value.
Notes:
Readonly ID of the auto generated receive multicast list associated with this enterprise profile
This attribute is named `receiveMultiCastListID` in VSD API.
"""
return self._receive_multi_cast_list_id
@receive_multi_cast_list_id.setter
def receive_multi_cast_list_id(self, value):
""" Set receive_multi_cast_list_id value.
Notes:
Readonly ID of the auto generated receive multicast list associated with this enterprise profile
This attribute is named `receiveMultiCastListID` in VSD API.
"""
self._receive_multi_cast_list_id = value
@property
def send_multi_cast_list_id(self):
""" Get send_multi_cast_list_id value.
Notes:
Readonly ID of the auto generated send multicast list associated with this enterprise profile
This attribute is named `sendMultiCastListID` in VSD API.
"""
return self._send_multi_cast_list_id
@send_multi_cast_list_id.setter
def send_multi_cast_list_id(self, value):
""" Set send_multi_cast_list_id value.
Notes:
Readonly ID of the auto generated send multicast list associated with this enterprise profile
This attribute is named `sendMultiCastListID` in VSD API.
"""
self._send_multi_cast_list_id = value
@property
def description(self):
""" Get description value.
Notes:
A description of the enterprise/organisation profile.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the enterprise/organisation profile.
"""
self._description = value
@property
def allow_advanced_qos_configuration(self):
""" Get allow_advanced_qos_configuration value.
Notes:
Controls whether this enterprise has access to advanced QoS settings.
This attribute is named `allowAdvancedQOSConfiguration` in VSD API.
"""
return self._allow_advanced_qos_configuration
@allow_advanced_qos_configuration.setter
def allow_advanced_qos_configuration(self, value):
""" Set allow_advanced_qos_configuration value.
Notes:
Controls whether this enterprise has access to advanced QoS settings.
This attribute is named `allowAdvancedQOSConfiguration` in VSD API.
"""
self._allow_advanced_qos_configuration = value
@property
def allow_gateway_management(self):
""" Get allow_gateway_management value.
Notes:
If set to true lets the enterprise admin create gateway templates and instances.
This attribute is named `allowGatewayManagement` in VSD API.
"""
return self._allow_gateway_management
@allow_gateway_management.setter
def allow_gateway_management(self, value):
""" Set allow_gateway_management value.
Notes:
If set to true lets the enterprise admin create gateway templates and instances.
This attribute is named `allowGatewayManagement` in VSD API.
"""
self._allow_gateway_management = value
@property
def allow_trusted_forwarding_class(self):
""" Get allow_trusted_forwarding_class value.
Notes:
Controls whether QoS policies and templates created under this enterprise set the trusted flag to true
This attribute is named `allowTrustedForwardingClass` in VSD API.
"""
return self._allow_trusted_forwarding_class
@allow_trusted_forwarding_class.setter
def allow_trusted_forwarding_class(self, value):
""" Set allow_trusted_forwarding_class value.
Notes:
Controls whether QoS policies and templates created under this enterprise set the trusted flag to true
This attribute is named `allowTrustedForwardingClass` in VSD API.
"""
self._allow_trusted_forwarding_class = value
@property
def allowed_forwarding_classes(self):
""" Get allowed_forwarding_classes value.
Notes:
Allowed Forwarding Classes for this enterprise. Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `allowedForwardingClasses` in VSD API.
"""
return self._allowed_forwarding_classes
@allowed_forwarding_classes.setter
def allowed_forwarding_classes(self, value):
""" Set allowed_forwarding_classes value.
Notes:
Allowed Forwarding Classes for this enterprise. Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `allowedForwardingClasses` in VSD API.
"""
self._allowed_forwarding_classes = value
@property
def floating_ips_quota(self):
""" Get floating_ips_quota value.
Notes:
Quota set for the number of floating IPs to be used by an enterprise.
This attribute is named `floatingIPsQuota` in VSD API.
"""
return self._floating_ips_quota
@floating_ips_quota.setter
def floating_ips_quota(self, value):
""" Set floating_ips_quota value.
Notes:
Quota set for the number of floating IPs to be used by an enterprise.
This attribute is named `floatingIPsQuota` in VSD API.
"""
self._floating_ips_quota = value
@property
def encryption_management_mode(self):
""" Get encryption_management_mode value.
Notes:
encryption management mode for this enterprise Possible values are DISABLED, MANAGED, .
This attribute is named `encryptionManagementMode` in VSD API.
"""
return self._encryption_management_mode
@encryption_management_mode.setter
def encryption_management_mode(self, value):
""" Set encryption_management_mode value.
Notes:
encryption management mode for this enterprise Possible values are DISABLED, MANAGED, .
This attribute is named `encryptionManagementMode` in VSD API.
"""
self._encryption_management_mode = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEnterpriseProfile
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ALLOWED_FORWARDING_CLASSES_A
var CONST_ALLOWED_FORWARDING_CLASSES_B
var CONST_ALLOWED_FORWARDING_CLASSES_C
var CONST_ALLOWED_FORWARDING_CLASSES_D
var CONST_ALLOWED_FORWARDING_CLASSES_E
var CONST_ALLOWED_FORWARDING_CLASSES_F
var CONST_ALLOWED_FORWARDING_CLASSES_G
var CONST_ALLOWED_FORWARDING_CLASSES_H
var CONST_ALLOWED_FORWARDING_CLASSES_NONE
var CONST_ENCRYPTION_MANAGEMENT_MODE_DISABLED
var CONST_ENCRYPTION_MANAGEMENT_MODE_MANAGED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var allow_advanced_qos_configuration
Get allow_advanced_qos_configuration value.
Notes: Controls whether this enterprise has access to advanced QoS settings.
This attribute is named `allowAdvancedQOSConfiguration` in VSD API.
var allow_gateway_management
Get allow_gateway_management value.
Notes: If set to true lets the enterprise admin create gateway templates and instances.
This attribute is named `allowGatewayManagement` in VSD API.
var allow_trusted_forwarding_class
Get allow_trusted_forwarding_class value.
Notes: Controls whether QoS policies and templates created under this enterprise set the trusted flag to true
This attribute is named `allowTrustedForwardingClass` in VSD API.
var allowed_forwarding_classes
Get allowed_forwarding_classes value.
Notes: Allowed Forwarding Classes for this enterprise. Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `allowedForwardingClasses` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the enterprise/organisation profile.
var dhcp_lease_interval
Get dhcp_lease_interval value.
Notes: DHCP Lease Interval (in hours) to be used by an enterprise.
This attribute is named `DHCPLeaseInterval` in VSD API.
var encryption_management_mode
Get encryption_management_mode value.
Notes: encryption management mode for this enterprise Possible values are DISABLED, MANAGED, .
This attribute is named `encryptionManagementMode` in VSD API.
var enterprises
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var external_services
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var floating_ips_quota
Get floating_ips_quota value.
Notes: Quota set for the number of floating IPs to be used by an enterprise.
This attribute is named `floatingIPsQuota` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var multi_cast_lists
var name
Get name value.
Notes: The unique name of the enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var receive_multi_cast_list_id
Get receive_multi_cast_list_id value.
Notes: Readonly ID of the auto generated receive multicast list associated with this enterprise profile
This attribute is named `receiveMultiCastListID` in VSD API.
var send_multi_cast_list_id
Get send_multi_cast_list_id value.
Notes: Readonly ID of the auto generated send multicast list associated with this enterprise profile
This attribute is named `sendMultiCastListID` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a EnterpriseProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> enterpriseprofile = NUEnterpriseProfile(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseProfile') >>> enterpriseprofile = NUEnterpriseProfile(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EnterpriseProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterpriseprofile = NUEnterpriseProfile(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseProfile')
>>> enterpriseprofile = NUEnterpriseProfile(data=my_dict)
"""
super(NUEnterpriseProfile, self).__init__()
# Read/Write Attributes
self._dhcp_lease_interval = None
self._name = None
self._last_updated_by = None
self._receive_multi_cast_list_id = None
self._send_multi_cast_list_id = None
self._description = None
self._allow_advanced_qos_configuration = None
self._allow_gateway_management = None
self._allow_trusted_forwarding_class = None
self._allowed_forwarding_classes = None
self._floating_ips_quota = None
self._encryption_management_mode = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="dhcp_lease_interval", remote_name="DHCPLeaseInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="receive_multi_cast_list_id", remote_name="receiveMultiCastListID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="send_multi_cast_list_id", remote_name="sendMultiCastListID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_advanced_qos_configuration", remote_name="allowAdvancedQOSConfiguration", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_gateway_management", remote_name="allowGatewayManagement", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_trusted_forwarding_class", remote_name="allowTrustedForwardingClass", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_forwarding_classes", remote_name="allowedForwardingClasses", attribute_type=list, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="floating_ips_quota", remote_name="floatingIPsQuota", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption_management_mode", remote_name="encryptionManagementMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'MANAGED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprises = NUEnterprisesFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.multi_cast_lists = NUMultiCastListsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.external_services = NUExternalServicesFetcher.fetcher_with_object(parent_object=self, relationship="member")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEnterpriseSecuredData
Represents a EnterpriseSecuredData in the VSD
Notes: This object represents the secured data object under the enterprise
class NUEnterpriseSecuredData(NURESTObject):
""" Represents a EnterpriseSecuredData in the VSD
Notes:
This object represents the secured data object under the enterprise
"""
__rest_name__ = "enterprisesecureddata"
__resource_name__ = "enterprisesecureddatas"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a EnterpriseSecuredData instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisesecureddata = NUEnterpriseSecuredData(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseSecuredData')
>>> enterprisesecureddata = NUEnterpriseSecuredData(data=my_dict)
"""
super(NUEnterpriseSecuredData, self).__init__()
# Read/Write Attributes
self._hash = None
self._last_updated_by = None
self._data = None
self._sek_id = None
self._keyserver_cert_serial_number = None
self._signed_hash = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="hash", remote_name="hash", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data", remote_name="data", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_id", remote_name="sekId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_cert_serial_number", remote_name="keyserverCertSerialNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="signed_hash", remote_name="signedHash", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def hash(self):
""" Get hash value.
Notes:
authentication hash
"""
return self._hash
@hash.setter
def hash(self, value):
""" Set hash value.
Notes:
authentication hash
"""
self._hash = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data(self):
""" Get data value.
Notes:
encrypted data
"""
return self._data
@data.setter
def data(self, value):
""" Set data value.
Notes:
encrypted data
"""
self._data = value
@property
def sek_id(self):
""" Get sek_id value.
Notes:
Seed Encryption Key id that encrypted this data
This attribute is named `sekId` in VSD API.
"""
return self._sek_id
@sek_id.setter
def sek_id(self, value):
""" Set sek_id value.
Notes:
Seed Encryption Key id that encrypted this data
This attribute is named `sekId` in VSD API.
"""
self._sek_id = value
@property
def keyserver_cert_serial_number(self):
""" Get keyserver_cert_serial_number value.
Notes:
Serial Number of the certificate needed to verify the encrypted data
This attribute is named `keyserverCertSerialNumber` in VSD API.
"""
return self._keyserver_cert_serial_number
@keyserver_cert_serial_number.setter
def keyserver_cert_serial_number(self, value):
""" Set keyserver_cert_serial_number value.
Notes:
Serial Number of the certificate needed to verify the encrypted data
This attribute is named `keyserverCertSerialNumber` in VSD API.
"""
self._keyserver_cert_serial_number = value
@property
def signed_hash(self):
""" Get signed_hash value.
Notes:
private key signed data
This attribute is named `signedHash` in VSD API.
"""
return self._signed_hash
@signed_hash.setter
def signed_hash(self, value):
""" Set signed_hash value.
Notes:
private key signed data
This attribute is named `signedHash` in VSD API.
"""
self._signed_hash = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEnterpriseSecuredData
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var data
Get data value.
Notes: encrypted data
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var hash
Get hash value.
Notes: authentication hash
var id
Get object id
var keyserver_cert_serial_number
Get keyserver_cert_serial_number value.
Notes: Serial Number of the certificate needed to verify the encrypted data
This attribute is named `keyserverCertSerialNumber` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var sek_id
Get sek_id value.
Notes: Seed Encryption Key id that encrypted this data
This attribute is named `sekId` in VSD API.
var signed_hash
Get signed_hash value.
Notes: private key signed data
This attribute is named `signedHash` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a EnterpriseSecuredData instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> enterprisesecureddata = NUEnterpriseSecuredData(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseSecuredData') >>> enterprisesecureddata = NUEnterpriseSecuredData(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EnterpriseSecuredData instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisesecureddata = NUEnterpriseSecuredData(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseSecuredData')
>>> enterprisesecureddata = NUEnterpriseSecuredData(data=my_dict)
"""
super(NUEnterpriseSecuredData, self).__init__()
# Read/Write Attributes
self._hash = None
self._last_updated_by = None
self._data = None
self._sek_id = None
self._keyserver_cert_serial_number = None
self._signed_hash = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="hash", remote_name="hash", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data", remote_name="data", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_id", remote_name="sekId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_cert_serial_number", remote_name="keyserverCertSerialNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="signed_hash", remote_name="signedHash", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEnterpriseSecurity
Represents a EnterpriseSecurity in the VSD
Notes: This object represents the enterprise security
class NUEnterpriseSecurity(NURESTObject):
""" Represents a EnterpriseSecurity in the VSD
Notes:
This object represents the enterprise security
"""
__rest_name__ = "enterprisesecurity"
__resource_name__ = "enterprisesecurities"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a EnterpriseSecurity instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisesecurity = NUEnterpriseSecurity(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseSecurity')
>>> enterprisesecurity = NUEnterpriseSecurity(data=my_dict)
"""
super(NUEnterpriseSecurity, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._gateway_security_revision = None
self._revision = None
self._enterprise_id = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_security_revision", remote_name="gatewaySecurityRevision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="revision", remote_name="revision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_secured_datas = NUEnterpriseSecuredDatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_security_revision(self):
""" Get gateway_security_revision value.
Notes:
change revision number for the gateway security data
This attribute is named `gatewaySecurityRevision` in VSD API.
"""
return self._gateway_security_revision
@gateway_security_revision.setter
def gateway_security_revision(self, value):
""" Set gateway_security_revision value.
Notes:
change revision number for the gateway security data
This attribute is named `gatewaySecurityRevision` in VSD API.
"""
self._gateway_security_revision = value
@property
def revision(self):
""" Get revision value.
Notes:
revision number for the enterprise security data
"""
return self._revision
@revision.setter
def revision(self, value):
""" Set revision value.
Notes:
revision number for the enterprise security data
"""
self._revision = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
The enterprise associated with this object. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
The enterprise associated with this object. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUEnterpriseSecurity
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var enterprise_id
Get enterprise_id value.
Notes: The enterprise associated with this object. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
var enterprise_secured_datas
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_security_revision
Get gateway_security_revision value.
Notes: change revision number for the gateway security data
This attribute is named `gatewaySecurityRevision` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var revision
Get revision value.
Notes: revision number for the enterprise security data
Methods
def __init__(
self, **kwargs)
Initializes a EnterpriseSecurity instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> enterprisesecurity = NUEnterpriseSecurity(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseSecurity') >>> enterprisesecurity = NUEnterpriseSecurity(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EnterpriseSecurity instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> enterprisesecurity = NUEnterpriseSecurity(id=u'xxxx-xxx-xxx-xxx', name=u'EnterpriseSecurity')
>>> enterprisesecurity = NUEnterpriseSecurity(data=my_dict)
"""
super(NUEnterpriseSecurity, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._gateway_security_revision = None
self._revision = None
self._enterprise_id = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_security_revision", remote_name="gatewaySecurityRevision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="revision", remote_name="revision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_secured_datas = NUEnterpriseSecuredDatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUEventLog
Represents a EventLog in the VSD
Notes: The API retrieves the events related to a particular entity
class NUEventLog(NURESTObject):
""" Represents a EventLog in the VSD
Notes:
The API retrieves the events related to a particular entity
"""
__rest_name__ = "eventlog"
__resource_name__ = "eventlogs"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a EventLog instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> eventlog = NUEventLog(id=u'xxxx-xxx-xxx-xxx', name=u'EventLog')
>>> eventlog = NUEventLog(data=my_dict)
"""
super(NUEventLog, self).__init__()
# Read/Write Attributes
self._diff = None
self._enterprise = None
self._entities = None
self._entity_id = None
self._entity_parent_id = None
self._entity_parent_type = None
self._entity_scope = None
self._entity_type = None
self._user = None
self._event_received_time = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="diff", remote_name="diff", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise", remote_name="enterprise", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entities", remote_name="entities", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_id", remote_name="entityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_parent_id", remote_name="entityParentID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_parent_type", remote_name="entityParentType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="entity_type", remote_name="entityType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user", remote_name="user", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_received_time", remote_name="eventReceivedTime", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def diff(self):
""" Get diff value.
Notes:
Holds the results of diff between two objects of same type.
"""
return self._diff
@diff.setter
def diff(self, value):
""" Set diff value.
Notes:
Holds the results of diff between two objects of same type.
"""
self._diff = value
@property
def enterprise(self):
""" Get enterprise value.
Notes:
The enterprise name of the user who triggered this event.
"""
return self._enterprise
@enterprise.setter
def enterprise(self, value):
""" Set enterprise value.
Notes:
The enterprise name of the user who triggered this event.
"""
self._enterprise = value
@property
def entities(self):
""" Get entities value.
Notes:
List of entities associated with the event.
"""
return self._entities
@entities.setter
def entities(self, value):
""" Set entities value.
Notes:
List of entities associated with the event.
"""
self._entities = value
@property
def entity_id(self):
""" Get entity_id value.
Notes:
The entity id associated with this event.
This attribute is named `entityID` in VSD API.
"""
return self._entity_id
@entity_id.setter
def entity_id(self, value):
""" Set entity_id value.
Notes:
The entity id associated with this event.
This attribute is named `entityID` in VSD API.
"""
self._entity_id = value
@property
def entity_parent_id(self):
""" Get entity_parent_id value.
Notes:
The entity parent id associated with this event. It can be null.
This attribute is named `entityParentID` in VSD API.
"""
return self._entity_parent_id
@entity_parent_id.setter
def entity_parent_id(self, value):
""" Set entity_parent_id value.
Notes:
The entity parent id associated with this event. It can be null.
This attribute is named `entityParentID` in VSD API.
"""
self._entity_parent_id = value
@property
def entity_parent_type(self):
""" Get entity_parent_type value.
Notes:
Event parent entity type. Generally reported against enterprise.
This attribute is named `entityParentType` in VSD API.
"""
return self._entity_parent_type
@entity_parent_type.setter
def entity_parent_type(self, value):
""" Set entity_parent_type value.
Notes:
Event parent entity type. Generally reported against enterprise.
This attribute is named `entityParentType` in VSD API.
"""
self._entity_parent_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def entity_type(self):
""" Get entity_type value.
Notes:
The entity type of this event. It may be Domain, VirtualMachine, etc.,
This attribute is named `entityType` in VSD API.
"""
return self._entity_type
@entity_type.setter
def entity_type(self, value):
""" Set entity_type value.
Notes:
The entity type of this event. It may be Domain, VirtualMachine, etc.,
This attribute is named `entityType` in VSD API.
"""
self._entity_type = value
@property
def user(self):
""" Get user value.
Notes:
The authenticated user who triggered this event.
"""
return self._user
@user.setter
def user(self, value):
""" Set user value.
Notes:
The authenticated user who triggered this event.
"""
self._user = value
@property
def event_received_time(self):
""" Get event_received_time value.
Notes:
The time that event was received.
This attribute is named `eventReceivedTime` in VSD API.
"""
return self._event_received_time
@event_received_time.setter
def event_received_time(self, value):
""" Set event_received_time value.
Notes:
The time that event was received.
This attribute is named `eventReceivedTime` in VSD API.
"""
self._event_received_time = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
The event type (CREATE, UPDATE or DELETE).
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
The event type (CREATE, UPDATE or DELETE).
"""
self._type = value
Ancestors (in MRO)
- NUEventLog
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var diff
Get diff value.
Notes: Holds the results of diff between two objects of same type.
var enterprise
Get enterprise value.
Notes: The enterprise name of the user who triggered this event.
var entities
Get entities value.
Notes: List of entities associated with the event.
var entity_id
Get entity_id value.
Notes: The entity id associated with this event.
This attribute is named `entityID` in VSD API.
var entity_parent_id
Get entity_parent_id value.
Notes: The entity parent id associated with this event. It can be null.
This attribute is named `entityParentID` in VSD API.
var entity_parent_type
Get entity_parent_type value.
Notes: Event parent entity type. Generally reported against enterprise.
This attribute is named `entityParentType` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var entity_type
Get entity_type value.
Notes: The entity type of this event. It may be Domain, VirtualMachine, etc.,
This attribute is named `entityType` in VSD API.
var errors
var event_received_time
Get event_received_time value.
Notes: The time that event was received.
This attribute is named `eventReceivedTime` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var type
Get type value.
Notes: The event type (CREATE, UPDATE or DELETE).
var user
Get user value.
Notes: The authenticated user who triggered this event.
Methods
def __init__(
self, **kwargs)
Initializes a EventLog instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> eventlog = NUEventLog(id=u'xxxx-xxx-xxx-xxx', name=u'EventLog') >>> eventlog = NUEventLog(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a EventLog instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> eventlog = NUEventLog(id=u'xxxx-xxx-xxx-xxx', name=u'EventLog')
>>> eventlog = NUEventLog(data=my_dict)
"""
super(NUEventLog, self).__init__()
# Read/Write Attributes
self._diff = None
self._enterprise = None
self._entities = None
self._entity_id = None
self._entity_parent_id = None
self._entity_parent_type = None
self._entity_scope = None
self._entity_type = None
self._user = None
self._event_received_time = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="diff", remote_name="diff", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise", remote_name="enterprise", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entities", remote_name="entities", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_id", remote_name="entityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_parent_id", remote_name="entityParentID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_parent_type", remote_name="entityParentType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="entity_type", remote_name="entityType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user", remote_name="user", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_received_time", remote_name="eventReceivedTime", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUExternalAppService
Represents a ExternalAppService in the VSD
Notes: Represents an External Service in the Application Designer.
class NUExternalAppService(NURESTObject):
""" Represents a ExternalAppService in the VSD
Notes:
Represents an External Service in the Application Designer.
"""
__rest_name__ = "externalappservice"
__resource_name__ = "externalappservices"
## Constants
CONST_EGRESS_TYPE_REDIRECT = "REDIRECT"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_INGRESS_TYPE_REDIRECT = "REDIRECT"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_EGRESS_TYPE_ROUTE = "ROUTE"
CONST_INGRESS_TYPE_ROUTE = "ROUTE"
def __init__(self, **kwargs):
""" Initializes a ExternalAppService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> externalappservice = NUExternalAppService(id=u'xxxx-xxx-xxx-xxx', name=u'ExternalAppService')
>>> externalappservice = NUExternalAppService(data=my_dict)
"""
super(NUExternalAppService, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._destination_nat_address = None
self._destination_nat_enabled = None
self._destination_nat_mask = None
self._metadata = None
self._egress_type = None
self._virtual_ip = None
self._virtual_ip_required = None
self._ingress_type = None
self._entity_scope = None
self._source_nat_address = None
self._source_nat_enabled = None
self._associated_service_egress_group_id = None
self._associated_service_egress_redirect_id = None
self._associated_service_ingress_group_id = None
self._associated_service_ingress_redirect_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_nat_address", remote_name="destinationNATAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_nat_enabled", remote_name="destinationNATEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_nat_mask", remote_name="destinationNATMask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata", remote_name="metadata", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="egress_type", remote_name="egressType", attribute_type=str, is_required=False, is_unique=False, choices=[u'REDIRECT', u'ROUTE'])
self.expose_attribute(local_name="virtual_ip", remote_name="virtualIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="virtual_ip_required", remote_name="virtualIPRequired", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_type", remote_name="ingressType", attribute_type=str, is_required=False, is_unique=False, choices=[u'REDIRECT', u'ROUTE'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_nat_address", remote_name="sourceNATAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_nat_enabled", remote_name="sourceNATEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_egress_group_id", remote_name="associatedServiceEgressGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_egress_redirect_id", remote_name="associatedServiceEgressRedirectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_ingress_group_id", remote_name="associatedServiceIngressGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_ingress_redirect_id", remote_name="associatedServiceIngressRedirectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the flow.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the flow.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the flow.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the flow.
"""
self._description = value
@property
def destination_nat_address(self):
""" Get destination_nat_address value.
Notes:
Destination NAT Address
This attribute is named `destinationNATAddress` in VSD API.
"""
return self._destination_nat_address
@destination_nat_address.setter
def destination_nat_address(self, value):
""" Set destination_nat_address value.
Notes:
Destination NAT Address
This attribute is named `destinationNATAddress` in VSD API.
"""
self._destination_nat_address = value
@property
def destination_nat_enabled(self):
""" Get destination_nat_enabled value.
Notes:
Boolean flag to indicate whether source NAT is enabled
This attribute is named `destinationNATEnabled` in VSD API.
"""
return self._destination_nat_enabled
@destination_nat_enabled.setter
def destination_nat_enabled(self, value):
""" Set destination_nat_enabled value.
Notes:
Boolean flag to indicate whether source NAT is enabled
This attribute is named `destinationNATEnabled` in VSD API.
"""
self._destination_nat_enabled = value
@property
def destination_nat_mask(self):
""" Get destination_nat_mask value.
Notes:
netmask of the Destination NAT
This attribute is named `destinationNATMask` in VSD API.
"""
return self._destination_nat_mask
@destination_nat_mask.setter
def destination_nat_mask(self, value):
""" Set destination_nat_mask value.
Notes:
netmask of the Destination NAT
This attribute is named `destinationNATMask` in VSD API.
"""
self._destination_nat_mask = value
@property
def metadata(self):
""" Get metadata value.
Notes:
metadata
"""
return self._metadata
@metadata.setter
def metadata(self, value):
""" Set metadata value.
Notes:
metadata
"""
self._metadata = value
@property
def egress_type(self):
""" Get egress_type value.
Notes:
Egress type.
This attribute is named `egressType` in VSD API.
"""
return self._egress_type
@egress_type.setter
def egress_type(self, value):
""" Set egress_type value.
Notes:
Egress type.
This attribute is named `egressType` in VSD API.
"""
self._egress_type = value
@property
def virtual_ip(self):
""" Get virtual_ip value.
Notes:
Virtual IP Address
This attribute is named `virtualIP` in VSD API.
"""
return self._virtual_ip
@virtual_ip.setter
def virtual_ip(self, value):
""" Set virtual_ip value.
Notes:
Virtual IP Address
This attribute is named `virtualIP` in VSD API.
"""
self._virtual_ip = value
@property
def virtual_ip_required(self):
""" Get virtual_ip_required value.
Notes:
Boolean flag to indicate whether we require a VIP
This attribute is named `virtualIPRequired` in VSD API.
"""
return self._virtual_ip_required
@virtual_ip_required.setter
def virtual_ip_required(self, value):
""" Set virtual_ip_required value.
Notes:
Boolean flag to indicate whether we require a VIP
This attribute is named `virtualIPRequired` in VSD API.
"""
self._virtual_ip_required = value
@property
def ingress_type(self):
""" Get ingress_type value.
Notes:
Ingress type.
This attribute is named `ingressType` in VSD API.
"""
return self._ingress_type
@ingress_type.setter
def ingress_type(self, value):
""" Set ingress_type value.
Notes:
Ingress type.
This attribute is named `ingressType` in VSD API.
"""
self._ingress_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def source_nat_address(self):
""" Get source_nat_address value.
Notes:
Source NAT Address
This attribute is named `sourceNATAddress` in VSD API.
"""
return self._source_nat_address
@source_nat_address.setter
def source_nat_address(self, value):
""" Set source_nat_address value.
Notes:
Source NAT Address
This attribute is named `sourceNATAddress` in VSD API.
"""
self._source_nat_address = value
@property
def source_nat_enabled(self):
""" Get source_nat_enabled value.
Notes:
Boolean flag to indicate whether source NAT is enabled
This attribute is named `sourceNATEnabled` in VSD API.
"""
return self._source_nat_enabled
@source_nat_enabled.setter
def source_nat_enabled(self, value):
""" Set source_nat_enabled value.
Notes:
Boolean flag to indicate whether source NAT is enabled
This attribute is named `sourceNATEnabled` in VSD API.
"""
self._source_nat_enabled = value
@property
def associated_service_egress_group_id(self):
""" Get associated_service_egress_group_id value.
Notes:
ID of service port group identifying the output ports
This attribute is named `associatedServiceEgressGroupID` in VSD API.
"""
return self._associated_service_egress_group_id
@associated_service_egress_group_id.setter
def associated_service_egress_group_id(self, value):
""" Set associated_service_egress_group_id value.
Notes:
ID of service port group identifying the output ports
This attribute is named `associatedServiceEgressGroupID` in VSD API.
"""
self._associated_service_egress_group_id = value
@property
def associated_service_egress_redirect_id(self):
""" Get associated_service_egress_redirect_id value.
Notes:
the redirect target ID that identifies the output ports
This attribute is named `associatedServiceEgressRedirectID` in VSD API.
"""
return self._associated_service_egress_redirect_id
@associated_service_egress_redirect_id.setter
def associated_service_egress_redirect_id(self, value):
""" Set associated_service_egress_redirect_id value.
Notes:
the redirect target ID that identifies the output ports
This attribute is named `associatedServiceEgressRedirectID` in VSD API.
"""
self._associated_service_egress_redirect_id = value
@property
def associated_service_ingress_group_id(self):
""" Get associated_service_ingress_group_id value.
Notes:
ID of service port group identifying the input ports
This attribute is named `associatedServiceIngressGroupID` in VSD API.
"""
return self._associated_service_ingress_group_id
@associated_service_ingress_group_id.setter
def associated_service_ingress_group_id(self, value):
""" Set associated_service_ingress_group_id value.
Notes:
ID of service port group identifying the input ports
This attribute is named `associatedServiceIngressGroupID` in VSD API.
"""
self._associated_service_ingress_group_id = value
@property
def associated_service_ingress_redirect_id(self):
""" Get associated_service_ingress_redirect_id value.
Notes:
the redirect target ID that identifies the input ports
This attribute is named `associatedServiceIngressRedirectID` in VSD API.
"""
return self._associated_service_ingress_redirect_id
@associated_service_ingress_redirect_id.setter
def associated_service_ingress_redirect_id(self, value):
""" Set associated_service_ingress_redirect_id value.
Notes:
the redirect target ID that identifies the input ports
This attribute is named `associatedServiceIngressRedirectID` in VSD API.
"""
self._associated_service_ingress_redirect_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUExternalAppService
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_EGRESS_TYPE_REDIRECT
var CONST_EGRESS_TYPE_ROUTE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_INGRESS_TYPE_REDIRECT
var CONST_INGRESS_TYPE_ROUTE
var resource_name
var rest_name
Instance variables
var associated_service_egress_group_id
Get associated_service_egress_group_id value.
Notes: ID of service port group identifying the output ports
This attribute is named `associatedServiceEgressGroupID` in VSD API.
var associated_service_egress_redirect_id
Get associated_service_egress_redirect_id value.
Notes: the redirect target ID that identifies the output ports
This attribute is named `associatedServiceEgressRedirectID` in VSD API.
var associated_service_ingress_group_id
Get associated_service_ingress_group_id value.
Notes: ID of service port group identifying the input ports
This attribute is named `associatedServiceIngressGroupID` in VSD API.
var associated_service_ingress_redirect_id
Get associated_service_ingress_redirect_id value.
Notes: the redirect target ID that identifies the input ports
This attribute is named `associatedServiceIngressRedirectID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the flow.
var destination_nat_address
Get destination_nat_address value.
Notes: Destination NAT Address
This attribute is named `destinationNATAddress` in VSD API.
var destination_nat_enabled
Get destination_nat_enabled value.
Notes: Boolean flag to indicate whether source NAT is enabled
This attribute is named `destinationNATEnabled` in VSD API.
var destination_nat_mask
Get destination_nat_mask value.
Notes: netmask of the Destination NAT
This attribute is named `destinationNATMask` in VSD API.
var egress_type
Get egress_type value.
Notes: Egress type.
This attribute is named `egressType` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ingress_type
Get ingress_type value.
Notes: Ingress type.
This attribute is named `ingressType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata
Get metadata value.
Notes: metadata
var metadatas
var name
Get name value.
Notes: Name of the flow.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var source_nat_address
Get source_nat_address value.
Notes: Source NAT Address
This attribute is named `sourceNATAddress` in VSD API.
var source_nat_enabled
Get source_nat_enabled value.
Notes: Boolean flag to indicate whether source NAT is enabled
This attribute is named `sourceNATEnabled` in VSD API.
var virtual_ip
Get virtual_ip value.
Notes: Virtual IP Address
This attribute is named `virtualIP` in VSD API.
var virtual_ip_required
Get virtual_ip_required value.
Notes: Boolean flag to indicate whether we require a VIP
This attribute is named `virtualIPRequired` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a ExternalAppService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> externalappservice = NUExternalAppService(id=u'xxxx-xxx-xxx-xxx', name=u'ExternalAppService') >>> externalappservice = NUExternalAppService(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a ExternalAppService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> externalappservice = NUExternalAppService(id=u'xxxx-xxx-xxx-xxx', name=u'ExternalAppService')
>>> externalappservice = NUExternalAppService(data=my_dict)
"""
super(NUExternalAppService, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._destination_nat_address = None
self._destination_nat_enabled = None
self._destination_nat_mask = None
self._metadata = None
self._egress_type = None
self._virtual_ip = None
self._virtual_ip_required = None
self._ingress_type = None
self._entity_scope = None
self._source_nat_address = None
self._source_nat_enabled = None
self._associated_service_egress_group_id = None
self._associated_service_egress_redirect_id = None
self._associated_service_ingress_group_id = None
self._associated_service_ingress_redirect_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_nat_address", remote_name="destinationNATAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_nat_enabled", remote_name="destinationNATEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_nat_mask", remote_name="destinationNATMask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata", remote_name="metadata", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="egress_type", remote_name="egressType", attribute_type=str, is_required=False, is_unique=False, choices=[u'REDIRECT', u'ROUTE'])
self.expose_attribute(local_name="virtual_ip", remote_name="virtualIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="virtual_ip_required", remote_name="virtualIPRequired", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_type", remote_name="ingressType", attribute_type=str, is_required=False, is_unique=False, choices=[u'REDIRECT', u'ROUTE'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_nat_address", remote_name="sourceNATAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="source_nat_enabled", remote_name="sourceNATEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_egress_group_id", remote_name="associatedServiceEgressGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_egress_redirect_id", remote_name="associatedServiceEgressRedirectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_ingress_group_id", remote_name="associatedServiceIngressGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_service_ingress_redirect_id", remote_name="associatedServiceIngressRedirectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUExternalService
Represents a ExternalService in the VSD
Notes: Representation of External Service.
class NUExternalService(NURESTObject):
""" Represents a ExternalService in the VSD
Notes:
Representation of External Service.
"""
__rest_name__ = "externalservice"
__resource_name__ = "externalservices"
## Constants
CONST_SERVICE_TYPE_L2 = "L2"
CONST_SERVICE_TYPE_L3 = "L3"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_STAGE_START = "START"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_DIRECTION_INGRESS = "INGRESS"
def __init__(self, **kwargs):
""" Initializes a ExternalService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> externalservice = NUExternalService(id=u'xxxx-xxx-xxx-xxx', name=u'ExternalService')
>>> externalservice = NUExternalService(data=my_dict)
"""
super(NUExternalService, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._service_type = None
self._description = None
self._direction = None
self._entity_scope = None
self._stage = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_type", remote_name="serviceType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L2', u'L3'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="direction", remote_name="direction", attribute_type=str, is_required=False, is_unique=False, choices=[u'INGRESS'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="stage", remote_name="stage", attribute_type=str, is_required=False, is_unique=False, choices=[u'START'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.end_points = NUEndPointsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
unique name of the External Service.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
unique name of the External Service.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def service_type(self):
""" Get service_type value.
Notes:
Type of the service.
This attribute is named `serviceType` in VSD API.
"""
return self._service_type
@service_type.setter
def service_type(self, value):
""" Set service_type value.
Notes:
Type of the service.
This attribute is named `serviceType` in VSD API.
"""
self._service_type = value
@property
def description(self):
""" Get description value.
Notes:
Description of the External Service.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the External Service.
"""
self._description = value
@property
def direction(self):
""" Get direction value.
Notes:
Direction
"""
return self._direction
@direction.setter
def direction(self, value):
""" Set direction value.
Notes:
Direction
"""
self._direction = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def stage(self):
""" Get stage value.
Notes:
Stage - START,END Possible values are START, .
"""
return self._stage
@stage.setter
def stage(self, value):
""" Set stage value.
Notes:
Stage - START,END Possible values are START, .
"""
self._stage = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUExternalService
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_DIRECTION_INGRESS
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SERVICE_TYPE_L2
var CONST_SERVICE_TYPE_L3
var CONST_STAGE_START
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the External Service.
var direction
Get direction value.
Notes: Direction
var end_points
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: unique name of the External Service.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var service_type
Get service_type value.
Notes: Type of the service.
This attribute is named `serviceType` in VSD API.
var stage
Get stage value.
Notes: Stage - START,END Possible values are START, .
Methods
def __init__(
self, **kwargs)
Initializes a ExternalService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> externalservice = NUExternalService(id=u'xxxx-xxx-xxx-xxx', name=u'ExternalService') >>> externalservice = NUExternalService(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a ExternalService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> externalservice = NUExternalService(id=u'xxxx-xxx-xxx-xxx', name=u'ExternalService')
>>> externalservice = NUExternalService(data=my_dict)
"""
super(NUExternalService, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._service_type = None
self._description = None
self._direction = None
self._entity_scope = None
self._stage = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_type", remote_name="serviceType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L2', u'L3'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="direction", remote_name="direction", attribute_type=str, is_required=False, is_unique=False, choices=[u'INGRESS'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="stage", remote_name="stage", attribute_type=str, is_required=False, is_unique=False, choices=[u'START'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.end_points = NUEndPointsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUFloatingIPACLTemplate
Represents a FloatingIPACLTemplate in the VSD
Notes: Defines the template for an Floating IP ACL
class NUFloatingIPACLTemplate(NURESTObject):
""" Represents a FloatingIPACLTemplate in the VSD
Notes:
Defines the template for an Floating IP ACL
"""
__rest_name__ = "egressfloatingipacltemplate"
__resource_name__ = "egressfloatingipacltemplates"
## Constants
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PRIORITY_TYPE_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PRIORITY_TYPE_TOP = "TOP"
CONST_PRIORITY_TYPE_BOTTOM = "BOTTOM"
def __init__(self, **kwargs):
""" Initializes a FloatingIPACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> floatingipacltemplate = NUFloatingIPACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIPACLTemplate')
>>> floatingipacltemplate = NUFloatingIPACLTemplate(data=my_dict)
"""
super(NUFloatingIPACLTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ipacl_template_entries = NUFloatingIPACLTemplateEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The name of the entity
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the entity
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def active(self):
""" Get active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
self._active = value
@property
def default_allow_ip(self):
""" Get default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
return self._default_allow_ip
@default_allow_ip.setter
def default_allow_ip(self, value):
""" Set default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
self._default_allow_ip = value
@property
def default_allow_non_ip(self):
""" Get default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
return self._default_allow_non_ip
@default_allow_non_ip.setter
def default_allow_non_ip(self, value):
""" Set default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
self._default_allow_non_ip = value
@property
def description(self):
""" Get description value.
Notes:
A description of the entity
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the entity
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def priority_type(self):
""" Get priority_type value.
Notes:
Priority type
This attribute is named `priorityType` in VSD API.
"""
return self._priority_type
@priority_type.setter
def priority_type(self, value):
""" Set priority_type value.
Notes:
Priority type
This attribute is named `priorityType` in VSD API.
"""
self._priority_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUFloatingIPACLTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_PRIORITY_TYPE_BOTTOM
var CONST_PRIORITY_TYPE_NONE
var CONST_PRIORITY_TYPE_TOP
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: If enabled, it means that this ACL or QOS entry is active
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var default_allow_ip
Get default_allow_ip value.
Notes: If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
var default_allow_non_ip
Get default_allow_non_ip value.
Notes: If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
var description
Get description value.
Notes: A description of the entity
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var floating_ipacl_template_entries
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: The name of the entity
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var priority_type
Get priority_type value.
Notes: Priority type
This attribute is named `priorityType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a FloatingIPACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> floatingipacltemplate = NUFloatingIPACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIPACLTemplate') >>> floatingipacltemplate = NUFloatingIPACLTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a FloatingIPACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> floatingipacltemplate = NUFloatingIPACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIPACLTemplate')
>>> floatingipacltemplate = NUFloatingIPACLTemplate(data=my_dict)
"""
super(NUFloatingIPACLTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.floating_ipacl_template_entries = NUFloatingIPACLTemplateEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUFloatingIPACLTemplateEntry
Represents a FloatingIPACLTemplateEntry in the VSD
Notes: Defines the template of Egress ACL Template entries
class NUFloatingIPACLTemplateEntry(NURESTObject):
""" Represents a FloatingIPACLTemplateEntry in the VSD
Notes:
Defines the template of Egress ACL Template entries
"""
__rest_name__ = "egressfloatingipaclentrytemplate"
__resource_name__ = "egressfloatingipaclentrytemplates"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ACTION_REDIRECT = "REDIRECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_NETWORK_TYPE_ENDPOINT_ZONE = "ENDPOINT_ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_LOCATION_TYPE_ANY = "ANY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_NETWORK_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_NETWORK_TYPE_ENDPOINT_DOMAIN = "ENDPOINT_DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_NETWORK_TYPE_ANY = "ANY"
CONST_LOCATION_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_LOCATION_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_LOCATION_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_LOCATION_TYPE_REDIRECTIONTARGET = "REDIRECTIONTARGET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ACTION_DROP = "DROP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_NETWORK_TYPE_INTERNET_POLICYGROUP = "INTERNET_POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_LOCATION_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_NETWORK_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ACTION_FORWARD = "FORWARD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_NETWORK_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_NETWORK_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_NETWORK_TYPE_ENDPOINT_SUBNET = "ENDPOINT_SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
def __init__(self, **kwargs):
""" Initializes a FloatingIPACLTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> floatingipacltemplateentry = NUFloatingIPACLTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIPACLTemplateEntry')
>>> floatingipacltemplateentry = NUFloatingIPACLTemplateEntry(data=my_dict)
"""
super(NUFloatingIPACLTemplateEntry, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._reflexive = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def action(self):
""" Get action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
"""
self._action = value
@property
def address_override(self):
""" Get address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
return self._address_override
@address_override.setter
def address_override(self, value):
""" Set address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
self._address_override = value
@property
def reflexive(self):
""" Get reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
return self._reflexive
@reflexive.setter
def reflexive(self, value):
""" Set reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
self._reflexive = value
@property
def description(self):
""" Get description value.
Notes:
Description of the ACL entry
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the ACL entry
"""
self._description = value
@property
def destination_port(self):
""" Get destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
return self._destination_port
@destination_port.setter
def destination_port(self, value):
""" Set destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
self._destination_port = value
@property
def network_id(self):
""" Get network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
return self._network_id
@network_id.setter
def network_id(self, value):
""" Set network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
self._network_id = value
@property
def network_type(self):
""" Get network_type value.
Notes:
Type of the source network - VM_SUBNET or VM_ZONE or VM_DOMAIN or SUBNET or ZONE or ENTERPRISE_NETWORK or PUBLIC_NETWORK or ANY
This attribute is named `networkType` in VSD API.
"""
return self._network_type
@network_type.setter
def network_type(self, value):
""" Set network_type value.
Notes:
Type of the source network - VM_SUBNET or VM_ZONE or VM_DOMAIN or SUBNET or ZONE or ENTERPRISE_NETWORK or PUBLIC_NETWORK or ANY
This attribute is named `networkType` in VSD API.
"""
self._network_type = value
@property
def flow_logging_enabled(self):
""" Get flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
return self._flow_logging_enabled
@flow_logging_enabled.setter
def flow_logging_enabled(self, value):
""" Set flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
self._flow_logging_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location_id(self):
""" Get location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
return self._location_id
@location_id.setter
def location_id(self, value):
""" Set location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
self._location_id = value
@property
def location_type(self):
""" Get location_type value.
Notes:
Type of the location entity - ANY or SUBNET or ZONE or VPORTTAG
This attribute is named `locationType` in VSD API.
"""
return self._location_type
@location_type.setter
def location_type(self, value):
""" Set location_type value.
Notes:
Type of the location entity - ANY or SUBNET or ZONE or VPORTTAG
This attribute is named `locationType` in VSD API.
"""
self._location_type = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def source_port(self):
""" Get source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
return self._source_port
@source_port.setter
def source_port(self, value):
""" Set source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
self._source_port = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def protocol(self):
""" Get protocol value.
Notes:
Protocol number that must be matched
"""
return self._protocol
@protocol.setter
def protocol(self, value):
""" Set protocol value.
Notes:
Protocol number that must be matched
"""
self._protocol = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def stats_id(self):
""" Get stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
return self._stats_id
@stats_id.setter
def stats_id(self, value):
""" Set stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
self._stats_id = value
@property
def stats_logging_enabled(self):
""" Get stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
return self._stats_logging_enabled
@stats_logging_enabled.setter
def stats_logging_enabled(self, value):
""" Set stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
self._stats_logging_enabled = value
@property
def ether_type(self):
""" Get ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
return self._ether_type
@ether_type.setter
def ether_type(self, value):
""" Set ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
self._ether_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUFloatingIPACLTemplateEntry
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_DROP
var CONST_ACTION_FORWARD
var CONST_ACTION_REDIRECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_LOCATION_TYPE_ANY
var CONST_LOCATION_TYPE_POLICYGROUP
var CONST_LOCATION_TYPE_REDIRECTIONTARGET
var CONST_LOCATION_TYPE_SUBNET
var CONST_LOCATION_TYPE_VPORTTAG
var CONST_LOCATION_TYPE_ZONE
var CONST_NETWORK_TYPE_ANY
var CONST_NETWORK_TYPE_ENDPOINT_DOMAIN
var CONST_NETWORK_TYPE_ENDPOINT_SUBNET
var CONST_NETWORK_TYPE_ENDPOINT_ZONE
var CONST_NETWORK_TYPE_ENTERPRISE_NETWORK
var CONST_NETWORK_TYPE_INTERNET_POLICYGROUP
var CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP
var CONST_NETWORK_TYPE_POLICYGROUP
var CONST_NETWORK_TYPE_PUBLIC_NETWORK
var CONST_NETWORK_TYPE_SUBNET
var CONST_NETWORK_TYPE_ZONE
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
var address_override
Get address_override value.
Notes: Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: ID of the associated live entity
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the ACL entry
var destination_port
Get destination_port value.
Notes: The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
var dscp
Get dscp value.
Notes: DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var ether_type
Get ether_type value.
Notes: Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_logging_enabled
Get flow_logging_enabled value.
Notes: Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location_id
Get location_id value.
Notes: The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
var location_type
Get location_type value.
Notes: Type of the location entity - ANY or SUBNET or ZONE or VPORTTAG
This attribute is named `locationType` in VSD API.
var metadatas
var network_id
Get network_id value.
Notes: The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
var network_type
Get network_type value.
Notes: Type of the source network - VM_SUBNET or VM_ZONE or VM_DOMAIN or SUBNET or ZONE or ENTERPRISE_NETWORK or PUBLIC_NETWORK or ANY
This attribute is named `networkType` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy.
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var protocol
Get protocol value.
Notes: Protocol number that must be matched
var reflexive
Get reflexive value.
Notes: True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
var source_port
Get source_port value.
Notes: Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
var stats_id
Get stats_id value.
Notes: The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
var stats_logging_enabled
Get stats_logging_enabled value.
Notes: Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a FloatingIPACLTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> floatingipacltemplateentry = NUFloatingIPACLTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIPACLTemplateEntry') >>> floatingipacltemplateentry = NUFloatingIPACLTemplateEntry(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a FloatingIPACLTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> floatingipacltemplateentry = NUFloatingIPACLTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIPACLTemplateEntry')
>>> floatingipacltemplateentry = NUFloatingIPACLTemplateEntry(data=my_dict)
"""
super(NUFloatingIPACLTemplateEntry, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._reflexive = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUFloatingIp
Represents a FloatingIp in the VSD
Notes: Floating IP that is associated to a Domain. This floating IP could be used in the VM interface for NAT functionality.
class NUFloatingIp(NURESTObject):
""" Represents a FloatingIp in the VSD
Notes:
Floating IP that is associated to a Domain. This floating IP could be used in the VM interface for NAT functionality.
"""
__rest_name__ = "floatingip"
__resource_name__ = "floatingips"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a FloatingIp instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> floatingip = NUFloatingIp(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIp')
>>> floatingip = NUFloatingIp(data=my_dict)
"""
super(NUFloatingIp, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._access_control = None
self._address = None
self._entity_scope = None
self._assigned = None
self._assigned_to_object_type = None
self._associated_shared_network_resource_id = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="access_control", remote_name="accessControl", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="assigned", remote_name="assigned", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="assigned_to_object_type", remote_name="assignedToObjectType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_shared_network_resource_id", remote_name="associatedSharedNetworkResourceID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def access_control(self):
""" Get access_control value.
Notes:
If access control is enabled this FIP is part of the Internet PG.
This attribute is named `accessControl` in VSD API.
"""
return self._access_control
@access_control.setter
def access_control(self, value):
""" Set access_control value.
Notes:
If access control is enabled this FIP is part of the Internet PG.
This attribute is named `accessControl` in VSD API.
"""
self._access_control = value
@property
def address(self):
""" Get address value.
Notes:
Floating IP address assigned to the Domain
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
Floating IP address assigned to the Domain
"""
self._address = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def assigned(self):
""" Get assigned value.
Notes:
True if this floating IP is assigned to a network interface else the value is false
"""
return self._assigned
@assigned.setter
def assigned(self, value):
""" Set assigned value.
Notes:
True if this floating IP is assigned to a network interface else the value is false
"""
self._assigned = value
@property
def assigned_to_object_type(self):
""" Get assigned_to_object_type value.
Notes:
The object type to which this floating ip is assigned. Eg. vport or virtualip
This attribute is named `assignedToObjectType` in VSD API.
"""
return self._assigned_to_object_type
@assigned_to_object_type.setter
def assigned_to_object_type(self, value):
""" Set assigned_to_object_type value.
Notes:
The object type to which this floating ip is assigned. Eg. vport or virtualip
This attribute is named `assignedToObjectType` in VSD API.
"""
self._assigned_to_object_type = value
@property
def associated_shared_network_resource_id(self):
""" Get associated_shared_network_resource_id value.
Notes:
Id of the shared network resource subnet which was used to get this floating IP address
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
"""
return self._associated_shared_network_resource_id
@associated_shared_network_resource_id.setter
def associated_shared_network_resource_id(self, value):
""" Set associated_shared_network_resource_id value.
Notes:
Id of the shared network resource subnet which was used to get this floating IP address
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
"""
self._associated_shared_network_resource_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUFloatingIp
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var access_control
Get access_control value.
Notes: If access control is enabled this FIP is part of the Internet PG.
This attribute is named `accessControl` in VSD API.
var address
Get address value.
Notes: Floating IP address assigned to the Domain
var assigned
Get assigned value.
Notes: True if this floating IP is assigned to a network interface else the value is false
var assigned_to_object_type
Get assigned_to_object_type value.
Notes: The object type to which this floating ip is assigned. Eg. vport or virtualip
This attribute is named `assignedToObjectType` in VSD API.
Get associated_shared_network_resource_id value.
Notes: Id of the shared network resource subnet which was used to get this floating IP address
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var vports
Methods
def __init__(
self, **kwargs)
Initializes a FloatingIp instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> floatingip = NUFloatingIp(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIp') >>> floatingip = NUFloatingIp(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a FloatingIp instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> floatingip = NUFloatingIp(id=u'xxxx-xxx-xxx-xxx', name=u'FloatingIp')
>>> floatingip = NUFloatingIp(data=my_dict)
"""
super(NUFloatingIp, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._access_control = None
self._address = None
self._entity_scope = None
self._assigned = None
self._assigned_to_object_type = None
self._associated_shared_network_resource_id = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="access_control", remote_name="accessControl", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="assigned", remote_name="assigned", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="assigned_to_object_type", remote_name="assignedToObjectType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_shared_network_resource_id", remote_name="associatedSharedNetworkResourceID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUFlow
Represents a Flow in the VSD
Notes: Flow represents the traffic between two different application tiers.
class NUFlow(NURESTObject):
""" Represents a Flow in the VSD
Notes:
Flow represents the traffic between two different application tiers.
"""
__rest_name__ = "flow"
__resource_name__ = "flows"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a Flow instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> flow = NUFlow(id=u'xxxx-xxx-xxx-xxx', name=u'Flow')
>>> flow = NUFlow(data=my_dict)
"""
super(NUFlow, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._destination_tier_id = None
self._metadata = None
self._entity_scope = None
self._origin_tier_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_tier_id", remote_name="destinationTierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata", remote_name="metadata", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="origin_tier_id", remote_name="originTierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.flow_forwarding_policies = NUFlowForwardingPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.flow_security_policies = NUFlowSecurityPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the flow.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the flow.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the flow.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the flow.
"""
self._description = value
@property
def destination_tier_id(self):
""" Get destination_tier_id value.
Notes:
Flow destination tier id.
This attribute is named `destinationTierID` in VSD API.
"""
return self._destination_tier_id
@destination_tier_id.setter
def destination_tier_id(self, value):
""" Set destination_tier_id value.
Notes:
Flow destination tier id.
This attribute is named `destinationTierID` in VSD API.
"""
self._destination_tier_id = value
@property
def metadata(self):
""" Get metadata value.
Notes:
Metadata field to store flow related data.
"""
return self._metadata
@metadata.setter
def metadata(self, value):
""" Set metadata value.
Notes:
Metadata field to store flow related data.
"""
self._metadata = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def origin_tier_id(self):
""" Get origin_tier_id value.
Notes:
Flow origin tier id.
This attribute is named `originTierID` in VSD API.
"""
return self._origin_tier_id
@origin_tier_id.setter
def origin_tier_id(self, value):
""" Set origin_tier_id value.
Notes:
Flow origin tier id.
This attribute is named `originTierID` in VSD API.
"""
self._origin_tier_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUFlow
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the flow.
var destination_tier_id
Get destination_tier_id value.
Notes: Flow destination tier id.
This attribute is named `destinationTierID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_forwarding_policies
var flow_security_policies
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata
Get metadata value.
Notes: Metadata field to store flow related data.
var metadatas
var name
Get name value.
Notes: Name of the flow.
var origin_tier_id
Get origin_tier_id value.
Notes: Flow origin tier id.
This attribute is named `originTierID` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a Flow instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> flow = NUFlow(id=u'xxxx-xxx-xxx-xxx', name=u'Flow') >>> flow = NUFlow(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Flow instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> flow = NUFlow(id=u'xxxx-xxx-xxx-xxx', name=u'Flow')
>>> flow = NUFlow(data=my_dict)
"""
super(NUFlow, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._destination_tier_id = None
self._metadata = None
self._entity_scope = None
self._origin_tier_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_tier_id", remote_name="destinationTierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata", remote_name="metadata", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="origin_tier_id", remote_name="originTierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.flow_forwarding_policies = NUFlowForwardingPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.flow_security_policies = NUFlowSecurityPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUFlowForwardingPolicy
Represents a FlowForwardingPolicy in the VSD
Notes: The redirect policy on the flow.
class NUFlowForwardingPolicy(NURESTObject):
""" Represents a FlowForwardingPolicy in the VSD
Notes:
The redirect policy on the flow.
"""
__rest_name__ = "flowforwardingpolicy"
__resource_name__ = "flowforwardingpolicies"
## Constants
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_TYPE_SERVICEPROVIDER = "SERVICEPROVIDER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSP = "VSP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_TYPE_SERVICECHAIN = "SERVICECHAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA = "METADATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ALARM = "ALARM"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
def __init__(self, **kwargs):
""" Initializes a FlowForwardingPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> flowforwardingpolicy = NUFlowForwardingPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'FlowForwardingPolicy')
>>> flowforwardingpolicy = NUFlowForwardingPolicy(data=my_dict)
"""
super(NUFlowForwardingPolicy, self).__init__()
# Read/Write Attributes
self._redirect_target_id = None
self._destination_address_overwrite = None
self._flow_id = None
self._entity_scope = None
self._source_address_overwrite = None
self._associated_application_service_id = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="redirect_target_id", remote_name="redirectTargetID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_address_overwrite", remote_name="destinationAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_id", remote_name="flowID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_address_overwrite", remote_name="sourceAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_service_id", remote_name="associatedApplicationServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False, choices=[u'SERVICECHAIN', u'SERVICEPROVIDER'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def redirect_target_id(self):
""" Get redirect_target_id value.
Notes:
The associated service id.
This attribute is named `redirectTargetID` in VSD API.
"""
return self._redirect_target_id
@redirect_target_id.setter
def redirect_target_id(self, value):
""" Set redirect_target_id value.
Notes:
The associated service id.
This attribute is named `redirectTargetID` in VSD API.
"""
self._redirect_target_id = value
@property
def destination_address_overwrite(self):
""" Get destination_address_overwrite value.
Notes:
The destination address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `destinationAddressOverwrite` in VSD API.
"""
return self._destination_address_overwrite
@destination_address_overwrite.setter
def destination_address_overwrite(self, value):
""" Set destination_address_overwrite value.
Notes:
The destination address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `destinationAddressOverwrite` in VSD API.
"""
self._destination_address_overwrite = value
@property
def flow_id(self):
""" Get flow_id value.
Notes:
The associated service id.
This attribute is named `flowID` in VSD API.
"""
return self._flow_id
@flow_id.setter
def flow_id(self, value):
""" Set flow_id value.
Notes:
The associated service id.
This attribute is named `flowID` in VSD API.
"""
self._flow_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def source_address_overwrite(self):
""" Get source_address_overwrite value.
Notes:
The source address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `sourceAddressOverwrite` in VSD API.
"""
return self._source_address_overwrite
@source_address_overwrite.setter
def source_address_overwrite(self, value):
""" Set source_address_overwrite value.
Notes:
The source address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `sourceAddressOverwrite` in VSD API.
"""
self._source_address_overwrite = value
@property
def associated_application_service_id(self):
""" Get associated_application_service_id value.
Notes:
The associated service id.
This attribute is named `associatedApplicationServiceID` in VSD API.
"""
return self._associated_application_service_id
@associated_application_service_id.setter
def associated_application_service_id(self, value):
""" Set associated_application_service_id value.
Notes:
The associated service id.
This attribute is named `associatedApplicationServiceID` in VSD API.
"""
self._associated_application_service_id = value
@property
def associated_network_object_id(self):
""" Get associated_network_object_id value.
Notes:
The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
return self._associated_network_object_id
@associated_network_object_id.setter
def associated_network_object_id(self, value):
""" Set associated_network_object_id value.
Notes:
The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
self._associated_network_object_id = value
@property
def associated_network_object_type(self):
""" Get associated_network_object_type value.
Notes:
The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
return self._associated_network_object_type
@associated_network_object_type.setter
def associated_network_object_type(self, value):
""" Set associated_network_object_type value.
Notes:
The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
self._associated_network_object_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
The redirect type.
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
The redirect type.
"""
self._type = value
Ancestors (in MRO)
- NUFlowForwardingPolicy
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_USER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_TYPE_SERVICECHAIN
var CONST_TYPE_SERVICEPROVIDER
var resource_name
var rest_name
Instance variables
var associated_application_service_id
Get associated_application_service_id value.
Notes: The associated service id.
This attribute is named `associatedApplicationServiceID` in VSD API.
var associated_network_object_id
Get associated_network_object_id value.
Notes: The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
var associated_network_object_type
Get associated_network_object_type value.
Notes: The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var destination_address_overwrite
Get destination_address_overwrite value.
Notes: The destination address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `destinationAddressOverwrite` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_id
Get flow_id value.
Notes: The associated service id.
This attribute is named `flowID` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var redirect_target_id
Get redirect_target_id value.
Notes: The associated service id.
This attribute is named `redirectTargetID` in VSD API.
var source_address_overwrite
Get source_address_overwrite value.
Notes: The source address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `sourceAddressOverwrite` in VSD API.
var type
Get type value.
Notes: The redirect type.
Methods
def __init__(
self, **kwargs)
Initializes a FlowForwardingPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> flowforwardingpolicy = NUFlowForwardingPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'FlowForwardingPolicy') >>> flowforwardingpolicy = NUFlowForwardingPolicy(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a FlowForwardingPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> flowforwardingpolicy = NUFlowForwardingPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'FlowForwardingPolicy')
>>> flowforwardingpolicy = NUFlowForwardingPolicy(data=my_dict)
"""
super(NUFlowForwardingPolicy, self).__init__()
# Read/Write Attributes
self._redirect_target_id = None
self._destination_address_overwrite = None
self._flow_id = None
self._entity_scope = None
self._source_address_overwrite = None
self._associated_application_service_id = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="redirect_target_id", remote_name="redirectTargetID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_address_overwrite", remote_name="destinationAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_id", remote_name="flowID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_address_overwrite", remote_name="sourceAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_service_id", remote_name="associatedApplicationServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False, choices=[u'SERVICECHAIN', u'SERVICEPROVIDER'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUFlowSecurityPolicy
Represents a FlowSecurityPolicy in the VSD
Notes: The security policy on the flow.
class NUFlowSecurityPolicy(NURESTObject):
""" Represents a FlowSecurityPolicy in the VSD
Notes:
The security policy on the flow.
"""
__rest_name__ = "flowsecuritypolicy"
__resource_name__ = "flowsecuritypolicies"
## Constants
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ACTION_REDIRECT = "REDIRECT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSP = "VSP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA = "METADATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ACTION_DROP = "DROP"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ALARM = "ALARM"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ACTION_FORWARD = "FORWARD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
def __init__(self, **kwargs):
""" Initializes a FlowSecurityPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> flowsecuritypolicy = NUFlowSecurityPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'FlowSecurityPolicy')
>>> flowsecuritypolicy = NUFlowSecurityPolicy(data=my_dict)
"""
super(NUFlowSecurityPolicy, self).__init__()
# Read/Write Attributes
self._action = None
self._destination_address_overwrite = None
self._flow_id = None
self._entity_scope = None
self._source_address_overwrite = None
self._priority = None
self._associated_application_service_id = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="destination_address_overwrite", remote_name="destinationAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_id", remote_name="flowID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_address_overwrite", remote_name="sourceAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_service_id", remote_name="associatedApplicationServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def action(self):
""" Get action value.
Notes:
The flow action. The action can be either FORWARD or DROP.
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The flow action. The action can be either FORWARD or DROP.
"""
self._action = value
@property
def destination_address_overwrite(self):
""" Get destination_address_overwrite value.
Notes:
The destination address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `destinationAddressOverwrite` in VSD API.
"""
return self._destination_address_overwrite
@destination_address_overwrite.setter
def destination_address_overwrite(self, value):
""" Set destination_address_overwrite value.
Notes:
The destination address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `destinationAddressOverwrite` in VSD API.
"""
self._destination_address_overwrite = value
@property
def flow_id(self):
""" Get flow_id value.
Notes:
The associated service id.
This attribute is named `flowID` in VSD API.
"""
return self._flow_id
@flow_id.setter
def flow_id(self, value):
""" Set flow_id value.
Notes:
The associated service id.
This attribute is named `flowID` in VSD API.
"""
self._flow_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def source_address_overwrite(self):
""" Get source_address_overwrite value.
Notes:
The source address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `sourceAddressOverwrite` in VSD API.
"""
return self._source_address_overwrite
@source_address_overwrite.setter
def source_address_overwrite(self, value):
""" Set source_address_overwrite value.
Notes:
The source address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `sourceAddressOverwrite` in VSD API.
"""
self._source_address_overwrite = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the flow security policy that determines the order of entries.
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the flow security policy that determines the order of entries.
"""
self._priority = value
@property
def associated_application_service_id(self):
""" Get associated_application_service_id value.
Notes:
The associated service id.
This attribute is named `associatedApplicationServiceID` in VSD API.
"""
return self._associated_application_service_id
@associated_application_service_id.setter
def associated_application_service_id(self, value):
""" Set associated_application_service_id value.
Notes:
The associated service id.
This attribute is named `associatedApplicationServiceID` in VSD API.
"""
self._associated_application_service_id = value
@property
def associated_network_object_id(self):
""" Get associated_network_object_id value.
Notes:
The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
return self._associated_network_object_id
@associated_network_object_id.setter
def associated_network_object_id(self, value):
""" Set associated_network_object_id value.
Notes:
The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
self._associated_network_object_id = value
@property
def associated_network_object_type(self):
""" Get associated_network_object_type value.
Notes:
The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
return self._associated_network_object_type
@associated_network_object_type.setter
def associated_network_object_type(self, value):
""" Set associated_network_object_type value.
Notes:
The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
self._associated_network_object_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUFlowSecurityPolicy
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_DROP
var CONST_ACTION_FORWARD
var CONST_ACTION_REDIRECT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_USER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The flow action. The action can be either FORWARD or DROP.
var associated_application_service_id
Get associated_application_service_id value.
Notes: The associated service id.
This attribute is named `associatedApplicationServiceID` in VSD API.
var associated_network_object_id
Get associated_network_object_id value.
Notes: The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
var associated_network_object_type
Get associated_network_object_type value.
Notes: The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var destination_address_overwrite
Get destination_address_overwrite value.
Notes: The destination address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `destinationAddressOverwrite` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_id
Get flow_id value.
Notes: The associated service id.
This attribute is named `flowID` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var priority
Get priority value.
Notes: The priority of the flow security policy that determines the order of entries.
var source_address_overwrite
Get source_address_overwrite value.
Notes: The source address overwrite. Needs to be in CIDR format x.x.x.x/n
This attribute is named `sourceAddressOverwrite` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a FlowSecurityPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> flowsecuritypolicy = NUFlowSecurityPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'FlowSecurityPolicy') >>> flowsecuritypolicy = NUFlowSecurityPolicy(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a FlowSecurityPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> flowsecuritypolicy = NUFlowSecurityPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'FlowSecurityPolicy')
>>> flowsecuritypolicy = NUFlowSecurityPolicy(data=my_dict)
"""
super(NUFlowSecurityPolicy, self).__init__()
# Read/Write Attributes
self._action = None
self._destination_address_overwrite = None
self._flow_id = None
self._entity_scope = None
self._source_address_overwrite = None
self._priority = None
self._associated_application_service_id = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=False, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="destination_address_overwrite", remote_name="destinationAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_id", remote_name="flowID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="source_address_overwrite", remote_name="sourceAddressOverwrite", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_service_id", remote_name="associatedApplicationServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGateway
Represents a Gateway in the VSD
Notes: Represents Gateway object.
class NUGateway(NURESTObject):
""" Represents a Gateway in the VSD
Notes:
Represents Gateway object.
"""
__rest_name__ = "gateway"
__resource_name__ = "gateways"
## Constants
CONST_PERSONALITY_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_PERSONALITY_VSA = "VSA"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERSONALITY_VSG = "VSG"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_PERSONALITY_OTHER = "OTHER"
CONST_PERSONALITY_NSG = "NSG"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_PERSONALITY_VRSG = "VRSG"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_PERSONALITY_DC7X50 = "DC7X50"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a Gateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gateway = NUGateway(id=u'xxxx-xxx-xxx-xxx', name=u'Gateway')
>>> gateway = NUGateway(data=my_dict)
"""
super(NUGateway, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._redundancy_group_id = None
self._peer = None
self._template_id = None
self._pending = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._vtep = None
self._auto_disc_gateway_id = None
self._external_id = None
self._system_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_group_id", remote_name="redundancyGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer", remote_name="peer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="pending", remote_name="pending", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=True, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="vtep", remote_name="vtep", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_disc_gateway_id", remote_name="autoDiscGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_id", remote_name="systemID", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.patnat_pools = NUPATNATPoolsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.wan_services = NUWANServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ports = NUPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Gateway
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Gateway
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def redundancy_group_id(self):
""" Get redundancy_group_id value.
Notes:
The Redundancy Gateway Group associated with this Gateway Instance. This is a read only attribute
This attribute is named `redundancyGroupID` in VSD API.
"""
return self._redundancy_group_id
@redundancy_group_id.setter
def redundancy_group_id(self, value):
""" Set redundancy_group_id value.
Notes:
The Redundancy Gateway Group associated with this Gateway Instance. This is a read only attribute
This attribute is named `redundancyGroupID` in VSD API.
"""
self._redundancy_group_id = value
@property
def peer(self):
""" Get peer value.
Notes:
The System ID of the peer gateway associated with this Gateway instance when it is discovered by the network manager (VSD) as being redundant.
"""
return self._peer
@peer.setter
def peer(self, value):
""" Set peer value.
Notes:
The System ID of the peer gateway associated with this Gateway instance when it is discovered by the network manager (VSD) as being redundant.
"""
self._peer = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the template that this Gateway was created from. This should be set when instantiating a Gateway
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the template that this Gateway was created from. This should be set when instantiating a Gateway
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def pending(self):
""" Get pending value.
Notes:
Indicates that this gateway is pending state or state. When in pending state it cannot be modified from REST.
"""
return self._pending
@pending.setter
def pending(self, value):
""" Set pending value.
Notes:
Indicates that this gateway is pending state or state. When in pending state it cannot be modified from REST.
"""
self._pending = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def personality(self):
""" Get personality value.
Notes:
Personality of the Gateway, cannot be changed after creation.
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
Personality of the Gateway, cannot be changed after creation.
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Gateway
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Gateway
"""
self._description = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def vtep(self):
""" Get vtep value.
Notes:
Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
"""
return self._vtep
@vtep.setter
def vtep(self, value):
""" Set vtep value.
Notes:
Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
"""
self._vtep = value
@property
def auto_disc_gateway_id(self):
""" Get auto_disc_gateway_id value.
Notes:
The Auto Discovered Gateway associated with this Gateway Instance
This attribute is named `autoDiscGatewayID` in VSD API.
"""
return self._auto_disc_gateway_id
@auto_disc_gateway_id.setter
def auto_disc_gateway_id(self, value):
""" Set auto_disc_gateway_id value.
Notes:
The Auto Discovered Gateway associated with this Gateway Instance
This attribute is named `autoDiscGatewayID` in VSD API.
"""
self._auto_disc_gateway_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def system_id(self):
""" Get system_id value.
Notes:
Identifier of the Gateway, cannot be modified after creation
This attribute is named `systemID` in VSD API.
"""
return self._system_id
@system_id.setter
def system_id(self, value):
""" Set system_id value.
Notes:
Identifier of the Gateway, cannot be modified after creation
This attribute is named `systemID` in VSD API.
"""
self._system_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUGateway
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PERSONALITY_DC7X50
var CONST_PERSONALITY_HARDWARE_VTEP
var CONST_PERSONALITY_NSG
var CONST_PERSONALITY_OTHER
var CONST_PERSONALITY_VRSG
var CONST_PERSONALITY_VSA
var CONST_PERSONALITY_VSG
var resource_name
var rest_name
Instance variables
var alarms
var auto_disc_gateway_id
Get auto_disc_gateway_id value.
Notes: The Auto Discovered Gateway associated with this Gateway Instance
This attribute is named `autoDiscGatewayID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Gateway
var enterprise_id
Get enterprise_id value.
Notes: The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Gateway
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var patnat_pools
var peer
Get peer value.
Notes: The System ID of the peer gateway associated with this Gateway instance when it is discovered by the network manager (VSD) as being redundant.
var pending
Get pending value.
Notes: Indicates that this gateway is pending state or state. When in pending state it cannot be modified from REST.
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var personality
Get personality value.
Notes: Personality of the Gateway, cannot be changed after creation.
var ports
var redundancy_group_id
Get redundancy_group_id value.
Notes: The Redundancy Gateway Group associated with this Gateway Instance. This is a read only attribute
This attribute is named `redundancyGroupID` in VSD API.
var system_id
Get system_id value.
Notes: Identifier of the Gateway, cannot be modified after creation
This attribute is named `systemID` in VSD API.
var template_id
Get template_id value.
Notes: The ID of the template that this Gateway was created from. This should be set when instantiating a Gateway
This attribute is named `templateID` in VSD API.
var vtep
Get vtep value.
Notes: Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
var wan_services
Methods
def __init__(
self, **kwargs)
Initializes a Gateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> gateway = NUGateway(id=u'xxxx-xxx-xxx-xxx', name=u'Gateway') >>> gateway = NUGateway(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Gateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gateway = NUGateway(id=u'xxxx-xxx-xxx-xxx', name=u'Gateway')
>>> gateway = NUGateway(data=my_dict)
"""
super(NUGateway, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._redundancy_group_id = None
self._peer = None
self._template_id = None
self._pending = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._vtep = None
self._auto_disc_gateway_id = None
self._external_id = None
self._system_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_group_id", remote_name="redundancyGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer", remote_name="peer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="pending", remote_name="pending", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=True, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="vtep", remote_name="vtep", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_disc_gateway_id", remote_name="autoDiscGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_id", remote_name="systemID", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.patnat_pools = NUPATNATPoolsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.wan_services = NUWANServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ports = NUPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGatewaySecuredData
Represents a GatewaySecuredData in the VSD
Notes: This object represents the secured data object under the gateway
class NUGatewaySecuredData(NURESTObject):
""" Represents a GatewaySecuredData in the VSD
Notes:
This object represents the secured data object under the gateway
"""
__rest_name__ = "gatewaysecureddata"
__resource_name__ = "gatewaysecureddatas"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a GatewaySecuredData instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaysecureddata = NUGatewaySecuredData(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecuredData')
>>> gatewaysecureddata = NUGatewaySecuredData(data=my_dict)
"""
super(NUGatewaySecuredData, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._data = None
self._gateway_cert_serial_number = None
self._keyserver_cert_serial_number = None
self._signed_data = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data", remote_name="data", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_cert_serial_number", remote_name="gatewayCertSerialNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_cert_serial_number", remote_name="keyserverCertSerialNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="signed_data", remote_name="signedData", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data(self):
""" Get data value.
Notes:
encrypted data
"""
return self._data
@data.setter
def data(self, value):
""" Set data value.
Notes:
encrypted data
"""
self._data = value
@property
def gateway_cert_serial_number(self):
""" Get gateway_cert_serial_number value.
Notes:
Serial Number of the certificate of the public key that encrypted this data
This attribute is named `gatewayCertSerialNumber` in VSD API.
"""
return self._gateway_cert_serial_number
@gateway_cert_serial_number.setter
def gateway_cert_serial_number(self, value):
""" Set gateway_cert_serial_number value.
Notes:
Serial Number of the certificate of the public key that encrypted this data
This attribute is named `gatewayCertSerialNumber` in VSD API.
"""
self._gateway_cert_serial_number = value
@property
def keyserver_cert_serial_number(self):
""" Get keyserver_cert_serial_number value.
Notes:
Serial Number of the certificate needed to verify the encrypted data
This attribute is named `keyserverCertSerialNumber` in VSD API.
"""
return self._keyserver_cert_serial_number
@keyserver_cert_serial_number.setter
def keyserver_cert_serial_number(self, value):
""" Set keyserver_cert_serial_number value.
Notes:
Serial Number of the certificate needed to verify the encrypted data
This attribute is named `keyserverCertSerialNumber` in VSD API.
"""
self._keyserver_cert_serial_number = value
@property
def signed_data(self):
""" Get signed_data value.
Notes:
private key signed data
This attribute is named `signedData` in VSD API.
"""
return self._signed_data
@signed_data.setter
def signed_data(self, value):
""" Set signed_data value.
Notes:
private key signed data
This attribute is named `signedData` in VSD API.
"""
self._signed_data = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUGatewaySecuredData
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var data
Get data value.
Notes: encrypted data
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_cert_serial_number
Get gateway_cert_serial_number value.
Notes: Serial Number of the certificate of the public key that encrypted this data
This attribute is named `gatewayCertSerialNumber` in VSD API.
var global_metadatas
var id
Get object id
var keyserver_cert_serial_number
Get keyserver_cert_serial_number value.
Notes: Serial Number of the certificate needed to verify the encrypted data
This attribute is named `keyserverCertSerialNumber` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var signed_data
Get signed_data value.
Notes: private key signed data
This attribute is named `signedData` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a GatewaySecuredData instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> gatewaysecureddata = NUGatewaySecuredData(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecuredData') >>> gatewaysecureddata = NUGatewaySecuredData(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a GatewaySecuredData instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaysecureddata = NUGatewaySecuredData(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecuredData')
>>> gatewaysecureddata = NUGatewaySecuredData(data=my_dict)
"""
super(NUGatewaySecuredData, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._data = None
self._gateway_cert_serial_number = None
self._keyserver_cert_serial_number = None
self._signed_data = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data", remote_name="data", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_cert_serial_number", remote_name="gatewayCertSerialNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_cert_serial_number", remote_name="keyserverCertSerialNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="signed_data", remote_name="signedData", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGatewaySecurity
Represents a GatewaySecurity in the VSD
Notes: This object represents the gateway security object
class NUGatewaySecurity(NURESTObject):
""" Represents a GatewaySecurity in the VSD
Notes:
This object represents the gateway security object
"""
__rest_name__ = "gatewaysecurity"
__resource_name__ = "gatewaysecurities"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a GatewaySecurity instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaysecurity = NUGatewaySecurity(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecurity')
>>> gatewaysecurity = NUGatewaySecurity(data=my_dict)
"""
super(NUGatewaySecurity, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._gateway_id = None
self._revision = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="revision", remote_name="revision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.gateway_secured_datas = NUGatewaySecuredDatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_id(self):
""" Get gateway_id value.
Notes:
The gateway associated with this object. This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
return self._gateway_id
@gateway_id.setter
def gateway_id(self, value):
""" Set gateway_id value.
Notes:
The gateway associated with this object. This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
self._gateway_id = value
@property
def revision(self):
""" Get revision value.
Notes:
change revision number for the gateway security data
"""
return self._revision
@revision.setter
def revision(self, value):
""" Set revision value.
Notes:
change revision number for the gateway security data
"""
self._revision = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUGatewaySecurity
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_id
Get gateway_id value.
Notes: The gateway associated with this object. This is a read only attribute
This attribute is named `gatewayID` in VSD API.
var gateway_secured_datas
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var revision
Get revision value.
Notes: change revision number for the gateway security data
Methods
def __init__(
self, **kwargs)
Initializes a GatewaySecurity instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> gatewaysecurity = NUGatewaySecurity(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecurity') >>> gatewaysecurity = NUGatewaySecurity(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a GatewaySecurity instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaysecurity = NUGatewaySecurity(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecurity')
>>> gatewaysecurity = NUGatewaySecurity(data=my_dict)
"""
super(NUGatewaySecurity, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._gateway_id = None
self._revision = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="revision", remote_name="revision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.gateway_secured_datas = NUGatewaySecuredDatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGatewaySecurityProfile
Represents a GatewaySecurityProfile in the VSD
Notes: This object represents the gateway security object
class NUGatewaySecurityProfile(NURESTObject):
""" Represents a GatewaySecurityProfile in the VSD
Notes:
This object represents the gateway security object
"""
__rest_name__ = "gatewaysecurityprofile"
__resource_name__ = "gatewaysecurityprofiles"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a GatewaySecurityProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaysecurityprofile = NUGatewaySecurityProfile(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecurityProfile')
>>> gatewaysecurityprofile = NUGatewaySecurityProfile(data=my_dict)
"""
super(NUGatewaySecurityProfile, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._gateway_id = None
self._revision = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="revision", remote_name="revision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.gateway_secured_datas = NUGatewaySecuredDatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_id(self):
""" Get gateway_id value.
Notes:
The gateway associated with this object. This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
return self._gateway_id
@gateway_id.setter
def gateway_id(self, value):
""" Set gateway_id value.
Notes:
The gateway associated with this object. This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
self._gateway_id = value
@property
def revision(self):
""" Get revision value.
Notes:
revision number for the gateway security profile data
"""
return self._revision
@revision.setter
def revision(self, value):
""" Set revision value.
Notes:
revision number for the gateway security profile data
"""
self._revision = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUGatewaySecurityProfile
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_id
Get gateway_id value.
Notes: The gateway associated with this object. This is a read only attribute
This attribute is named `gatewayID` in VSD API.
var gateway_secured_datas
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var revision
Get revision value.
Notes: revision number for the gateway security profile data
Methods
def __init__(
self, **kwargs)
Initializes a GatewaySecurityProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> gatewaysecurityprofile = NUGatewaySecurityProfile(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecurityProfile') >>> gatewaysecurityprofile = NUGatewaySecurityProfile(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a GatewaySecurityProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaysecurityprofile = NUGatewaySecurityProfile(id=u'xxxx-xxx-xxx-xxx', name=u'GatewaySecurityProfile')
>>> gatewaysecurityprofile = NUGatewaySecurityProfile(data=my_dict)
"""
super(NUGatewaySecurityProfile, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._gateway_id = None
self._revision = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="revision", remote_name="revision", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.gateway_secured_datas = NUGatewaySecuredDatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGatewayTemplate
Represents a GatewayTemplate in the VSD
Notes: Represents Gateway Template object.
class NUGatewayTemplate(NURESTObject):
""" Represents a GatewayTemplate in the VSD
Notes:
Represents Gateway Template object.
"""
__rest_name__ = "gatewaytemplate"
__resource_name__ = "gatewaytemplates"
## Constants
CONST_PERSONALITY_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_PERSONALITY_VSA = "VSA"
CONST_PERSONALITY_VSG = "VSG"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PERSONALITY_OTHER = "OTHER"
CONST_PERSONALITY_NSG = "NSG"
CONST_PERSONALITY_VRSG = "VRSG"
CONST_PERSONALITY_DC7X50 = "DC7X50"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a GatewayTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaytemplate = NUGatewayTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'GatewayTemplate')
>>> gatewaytemplate = NUGatewayTemplate(data=my_dict)
"""
super(NUGatewayTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=True, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.port_templates = NUPortTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Gateway
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Gateway
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def personality(self):
""" Get personality value.
Notes:
Personality of the Gateway, cannot be changed after creation.
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
Personality of the Gateway, cannot be changed after creation.
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Gateway
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Gateway
"""
self._description = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUGatewayTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERSONALITY_DC7X50
var CONST_PERSONALITY_HARDWARE_VTEP
var CONST_PERSONALITY_NSG
var CONST_PERSONALITY_OTHER
var CONST_PERSONALITY_VRSG
var CONST_PERSONALITY_VSA
var CONST_PERSONALITY_VSG
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Gateway
var enterprise_id
Get enterprise_id value.
Notes: The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Gateway
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var personality
Get personality value.
Notes: Personality of the Gateway, cannot be changed after creation.
var port_templates
Methods
def __init__(
self, **kwargs)
Initializes a GatewayTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> gatewaytemplate = NUGatewayTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'GatewayTemplate') >>> gatewaytemplate = NUGatewayTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a GatewayTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> gatewaytemplate = NUGatewayTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'GatewayTemplate')
>>> gatewaytemplate = NUGatewayTemplate(data=my_dict)
"""
super(NUGatewayTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=True, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.port_templates = NUPortTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGlobalMetadata
Represents a GlobalMetadata in the VSD
Notes: Metadata associated to a entity.
class NUGlobalMetadata(NURESTObject):
""" Represents a GlobalMetadata in the VSD
Notes:
Metadata associated to a entity.
"""
__rest_name__ = "globalmetadata"
__resource_name__ = "globalmetadatas"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a GlobalMetadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> globalmetadata = NUGlobalMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'GlobalMetadata')
>>> globalmetadata = NUGlobalMetadata(data=my_dict)
"""
super(NUGlobalMetadata, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._metadata_tag_ids = None
self._network_notification_disabled = None
self._blob = None
self._global_metadata = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_tag_ids", remote_name="metadataTagIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_notification_disabled", remote_name="networkNotificationDisabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="blob", remote_name="blob", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="global_metadata", remote_name="global", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
name of the Metadata.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
name of the Metadata.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Metadata.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Metadata.
"""
self._description = value
@property
def metadata_tag_ids(self):
""" Get metadata_tag_ids value.
Notes:
metadata tag IDs associated with this metadata you can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
"""
return self._metadata_tag_ids
@metadata_tag_ids.setter
def metadata_tag_ids(self, value):
""" Set metadata_tag_ids value.
Notes:
metadata tag IDs associated with this metadata you can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
"""
self._metadata_tag_ids = value
@property
def network_notification_disabled(self):
""" Get network_notification_disabled value.
Notes:
specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
"""
return self._network_notification_disabled
@network_notification_disabled.setter
def network_notification_disabled(self, value):
""" Set network_notification_disabled value.
Notes:
specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
"""
self._network_notification_disabled = value
@property
def blob(self):
""" Get blob value.
Notes:
Metadata that describes about the entity attached to it.
"""
return self._blob
@blob.setter
def blob(self, value):
""" Set blob value.
Notes:
Metadata that describes about the entity attached to it.
"""
self._blob = value
@property
def global_metadata(self):
""" Get global_metadata value.
Notes:
specifies metadata is global or local
This attribute is named `global` in VSD API.
"""
return self._global_metadata
@global_metadata.setter
def global_metadata(self, value):
""" Set global_metadata value.
Notes:
specifies metadata is global or local
This attribute is named `global` in VSD API.
"""
self._global_metadata = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUGlobalMetadata
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var blob
Get blob value.
Notes: Metadata that describes about the entity attached to it.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the Metadata.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadata
Get global_metadata value.
Notes: specifies metadata is global or local
This attribute is named `global` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_tag_ids
Get metadata_tag_ids value.
Notes: metadata tag IDs associated with this metadata you can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
var metadatas
var name
Get name value.
Notes: name of the Metadata.
var network_notification_disabled
Get network_notification_disabled value.
Notes: specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a GlobalMetadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> globalmetadata = NUGlobalMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'GlobalMetadata') >>> globalmetadata = NUGlobalMetadata(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a GlobalMetadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> globalmetadata = NUGlobalMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'GlobalMetadata')
>>> globalmetadata = NUGlobalMetadata(data=my_dict)
"""
super(NUGlobalMetadata, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._metadata_tag_ids = None
self._network_notification_disabled = None
self._blob = None
self._global_metadata = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_tag_ids", remote_name="metadataTagIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_notification_disabled", remote_name="networkNotificationDisabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="blob", remote_name="blob", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="global_metadata", remote_name="global", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGroup
Represents a Group in the VSD
Notes: Identifies a group within an enterprise
class NUGroup(NURESTObject):
""" Represents a Group in the VSD
Notes:
Identifies a group within an enterprise
"""
__rest_name__ = "group"
__resource_name__ = "groups"
## Constants
CONST_MANAGEMENT_MODE_CMS = "CMS"
CONST_ROLE_CMS = "CMS"
CONST_ROLE_UNKNOWN = "UNKNOWN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ROLE_ORGNETWORKDESIGNER = "ORGNETWORKDESIGNER"
CONST_ROLE_CSPOPERATOR = "CSPOPERATOR"
CONST_ROLE_USER = "USER"
CONST_ROLE_ORGAPPDESIGNER = "ORGAPPDESIGNER"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ROLE_JMS = "JMS"
CONST_ROLE_ORGUSER = "ORGUSER"
CONST_ROLE_CSPROOT = "CSPROOT"
CONST_ROLE_SYSTEM = "SYSTEM"
CONST_ROLE_ORGADMIN = "ORGADMIN"
CONST_MANAGEMENT_MODE_DEFAULT = "DEFAULT"
def __init__(self, **kwargs):
""" Initializes a Group instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> group = NUGroup(id=u'xxxx-xxx-xxx-xxx', name=u'Group')
>>> group = NUGroup(data=my_dict)
"""
super(NUGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._management_mode = None
self._last_updated_by = None
self._account_restrictions = None
self._description = None
self._restriction_date = None
self._entity_scope = None
self._role = None
self._private = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="management_mode", remote_name="managementMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'CMS', u'DEFAULT'])
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="account_restrictions", remote_name="accountRestrictions", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="restriction_date", remote_name="restrictionDate", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="role", remote_name="role", attribute_type=str, is_required=False, is_unique=False, choices=[u'CMS', u'CSPOPERATOR', u'CSPROOT', u'JMS', u'ORGADMIN', u'ORGAPPDESIGNER', u'ORGNETWORKDESIGNER', u'ORGUSER', u'SYSTEM', u'UNKNOWN', u'USER'])
self.expose_attribute(local_name="private", remote_name="private", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.users = NUUsersFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
A unique name of the group
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
A unique name of the group
"""
self._name = value
@property
def management_mode(self):
""" Get management_mode value.
Notes:
Management mode of the user object - allows for override of external authorization and syncup
This attribute is named `managementMode` in VSD API.
"""
return self._management_mode
@management_mode.setter
def management_mode(self, value):
""" Set management_mode value.
Notes:
Management mode of the user object - allows for override of external authorization and syncup
This attribute is named `managementMode` in VSD API.
"""
self._management_mode = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def account_restrictions(self):
""" Get account_restrictions value.
Notes:
Determines whether group is disabled or not.
This attribute is named `accountRestrictions` in VSD API.
"""
return self._account_restrictions
@account_restrictions.setter
def account_restrictions(self, value):
""" Set account_restrictions value.
Notes:
Determines whether group is disabled or not.
This attribute is named `accountRestrictions` in VSD API.
"""
self._account_restrictions = value
@property
def description(self):
""" Get description value.
Notes:
Description of the group
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the group
"""
self._description = value
@property
def restriction_date(self):
""" Get restriction_date value.
Notes:
When the group was disabled.
This attribute is named `restrictionDate` in VSD API.
"""
return self._restriction_date
@restriction_date.setter
def restriction_date(self, value):
""" Set restriction_date value.
Notes:
When the group was disabled.
This attribute is named `restrictionDate` in VSD API.
"""
self._restriction_date = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def role(self):
""" Get role value.
Notes:
The role associated with this group.
"""
return self._role
@role.setter
def role(self, value):
""" Set role value.
Notes:
The role associated with this group.
"""
self._role = value
@property
def private(self):
""" Get private value.
Notes:
A private group is visible only by the owner of the group. Public groups are visible by all users in the enterprise
"""
return self._private
@private.setter
def private(self, value):
""" Set private value.
Notes:
A private group is visible only by the owner of the group. Public groups are visible by all users in the enterprise
"""
self._private = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUGroup
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MANAGEMENT_MODE_CMS
var CONST_MANAGEMENT_MODE_DEFAULT
var CONST_ROLE_CMS
var CONST_ROLE_CSPOPERATOR
var CONST_ROLE_CSPROOT
var CONST_ROLE_JMS
var CONST_ROLE_ORGADMIN
var CONST_ROLE_ORGAPPDESIGNER
var CONST_ROLE_ORGNETWORKDESIGNER
var CONST_ROLE_ORGUSER
var CONST_ROLE_SYSTEM
var CONST_ROLE_UNKNOWN
var CONST_ROLE_USER
var resource_name
var rest_name
Instance variables
var account_restrictions
Get account_restrictions value.
Notes: Determines whether group is disabled or not.
This attribute is named `accountRestrictions` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the group
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var management_mode
Get management_mode value.
Notes: Management mode of the user object - allows for override of external authorization and syncup
This attribute is named `managementMode` in VSD API.
var metadatas
var name
Get name value.
Notes: A unique name of the group
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var private
Get private value.
Notes: A private group is visible only by the owner of the group. Public groups are visible by all users in the enterprise
var restriction_date
Get restriction_date value.
Notes: When the group was disabled.
This attribute is named `restrictionDate` in VSD API.
var role
Get role value.
Notes: The role associated with this group.
var users
Methods
def __init__(
self, **kwargs)
Initializes a Group instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> group = NUGroup(id=u'xxxx-xxx-xxx-xxx', name=u'Group') >>> group = NUGroup(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Group instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> group = NUGroup(id=u'xxxx-xxx-xxx-xxx', name=u'Group')
>>> group = NUGroup(data=my_dict)
"""
super(NUGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._management_mode = None
self._last_updated_by = None
self._account_restrictions = None
self._description = None
self._restriction_date = None
self._entity_scope = None
self._role = None
self._private = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="management_mode", remote_name="managementMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'CMS', u'DEFAULT'])
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="account_restrictions", remote_name="accountRestrictions", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="restriction_date", remote_name="restrictionDate", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="role", remote_name="role", attribute_type=str, is_required=False, is_unique=False, choices=[u'CMS', u'CSPOPERATOR', u'CSPROOT', u'JMS', u'ORGADMIN', u'ORGAPPDESIGNER', u'ORGNETWORKDESIGNER', u'ORGUSER', u'SYSTEM', u'UNKNOWN', u'USER'])
self.expose_attribute(local_name="private", remote_name="private", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.users = NUUsersFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUGroupKeyEncryptionProfile
Represents a GroupKeyEncryptionProfile in the VSD
Notes: Represents a Group Key Profile
class NUGroupKeyEncryptionProfile(NURESTObject):
""" Represents a GroupKeyEncryptionProfile in the VSD
Notes:
Represents a Group Key Profile
"""
__rest_name__ = "groupkeyencryptionprofile"
__resource_name__ = "groupkeyencryptionprofiles"
## Constants
CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA = "SHA512withRSA"
CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA = "SHA256withRSA"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA = "SHA1withRSA"
CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA512 = "HMAC_SHA512"
CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC = "TRIPLE_DES_CBC"
CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA1 = "HMAC_SHA1"
CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA1 = "HMAC_SHA1"
CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA256 = "HMAC_SHA256"
CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA = "SHA512withRSA"
CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA384 = "HMAC_SHA384"
CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA = "SHA1withRSA"
CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA = "SHA384withRSA"
CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA = "SHA224withRSA"
CONST_TRAFFIC_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC = "TRIPLE_DES_CBC"
CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_256_CBC = "AES_256_CBC"
CONST_SEK_PAYLOAD_ENCRYPTION_ALGORITHM_RSA_1024 = "RSA_1024"
CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA = "SHA384withRSA"
CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA256 = "HMAC_SHA256"
CONST_TRAFFIC_ENCRYPTION_ALGORITHM_AES_192_CBC = "AES_192_CBC"
CONST_TRAFFIC_ENCRYPTION_ALGORITHM_AES_256_CBC = "AES_256_CBC"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA = "SHA256withRSA"
CONST_TRAFFIC_ENCRYPTION_ALGORITHM_AES_128_CBC = "AES_128_CBC"
CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA512 = "HMAC_SHA512"
CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_MD5 = "HMAC_MD5"
CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_128_CBC = "AES_128_CBC"
CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA = "SHA224withRSA"
def __init__(self, **kwargs):
""" Initializes a GroupKeyEncryptionProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> groupkeyencryptionprofile = NUGroupKeyEncryptionProfile(id=u'xxxx-xxx-xxx-xxx', name=u'GroupKeyEncryptionProfile')
>>> groupkeyencryptionprofile = NUGroupKeyEncryptionProfile(data=my_dict)
"""
super(NUGroupKeyEncryptionProfile, self).__init__()
# Read/Write Attributes
self._sek_generation_interval = None
self._sek_lifetime = None
self._sek_payload_encryption_algorithm = None
self._sek_payload_encryption_bc_algorithm = None
self._sek_payload_encryption_key_length = None
self._sek_payload_signing_algorithm = None
self._name = None
self._last_updated_by = None
self._seed_generation_interval = None
self._seed_lifetime = None
self._seed_payload_authentication_algorithm = None
self._seed_payload_authentication_bc_algorithm = None
self._seed_payload_authentication_key_length = None
self._seed_payload_encryption_algorithm = None
self._seed_payload_encryption_bc_algorithm = None
self._seed_payload_encryption_key_length = None
self._seed_payload_signing_algorithm = None
self._description = None
self._entity_scope = None
self._traffic_authentication_algorithm = None
self._traffic_encryption_algorithm = None
self._traffic_encryption_key_lifetime = None
self._external_id = None
self.expose_attribute(local_name="sek_generation_interval", remote_name="SEKGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_lifetime", remote_name="SEKLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_payload_encryption_algorithm", remote_name="SEKPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'RSA_1024'])
self.expose_attribute(local_name="sek_payload_encryption_bc_algorithm", remote_name="SEKPayloadEncryptionBCAlgorithm", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_payload_encryption_key_length", remote_name="SEKPayloadEncryptionKeyLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_payload_signing_algorithm", remote_name="SEKPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_generation_interval", remote_name="seedGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_lifetime", remote_name="seedLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_authentication_algorithm", remote_name="seedPayloadAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA512'])
self.expose_attribute(local_name="seed_payload_authentication_bc_algorithm", remote_name="seedPayloadAuthenticationBCAlgorithm", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_authentication_key_length", remote_name="seedPayloadAuthenticationKeyLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_encryption_algorithm", remote_name="seedPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="seed_payload_encryption_bc_algorithm", remote_name="seedPayloadEncryptionBCAlgorithm", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_encryption_key_length", remote_name="seedPayloadEncryptionKeyLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_signing_algorithm", remote_name="seedPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="traffic_authentication_algorithm", remote_name="trafficAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_MD5', u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA384', u'HMAC_SHA512'])
self.expose_attribute(local_name="traffic_encryption_algorithm", remote_name="trafficEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_192_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="traffic_encryption_key_lifetime", remote_name="trafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def sek_generation_interval(self):
""" Get sek_generation_interval value.
Notes:
Group Key SEK Generation Interval in Seconds. Min=1, Max=86400
This attribute is named `SEKGenerationInterval` in VSD API.
"""
return self._sek_generation_interval
@sek_generation_interval.setter
def sek_generation_interval(self, value):
""" Set sek_generation_interval value.
Notes:
Group Key SEK Generation Interval in Seconds. Min=1, Max=86400
This attribute is named `SEKGenerationInterval` in VSD API.
"""
self._sek_generation_interval = value
@property
def sek_lifetime(self):
""" Get sek_lifetime value.
Notes:
Group Key SEK Lifetime in Seconds. Min=1, Max=86400
This attribute is named `SEKLifetime` in VSD API.
"""
return self._sek_lifetime
@sek_lifetime.setter
def sek_lifetime(self, value):
""" Set sek_lifetime value.
Notes:
Group Key SEK Lifetime in Seconds. Min=1, Max=86400
This attribute is named `SEKLifetime` in VSD API.
"""
self._sek_lifetime = value
@property
def sek_payload_encryption_algorithm(self):
""" Get sek_payload_encryption_algorithm value.
Notes:
Group Key SEK Payload Encryption Algorithm.
This attribute is named `SEKPayloadEncryptionAlgorithm` in VSD API.
"""
return self._sek_payload_encryption_algorithm
@sek_payload_encryption_algorithm.setter
def sek_payload_encryption_algorithm(self, value):
""" Set sek_payload_encryption_algorithm value.
Notes:
Group Key SEK Payload Encryption Algorithm.
This attribute is named `SEKPayloadEncryptionAlgorithm` in VSD API.
"""
self._sek_payload_encryption_algorithm = value
@property
def sek_payload_encryption_bc_algorithm(self):
""" Get sek_payload_encryption_bc_algorithm value.
Notes:
Group Key Sek Payload Encryption BC Algorithm (read only)
This attribute is named `SEKPayloadEncryptionBCAlgorithm` in VSD API.
"""
return self._sek_payload_encryption_bc_algorithm
@sek_payload_encryption_bc_algorithm.setter
def sek_payload_encryption_bc_algorithm(self, value):
""" Set sek_payload_encryption_bc_algorithm value.
Notes:
Group Key Sek Payload Encryption BC Algorithm (read only)
This attribute is named `SEKPayloadEncryptionBCAlgorithm` in VSD API.
"""
self._sek_payload_encryption_bc_algorithm = value
@property
def sek_payload_encryption_key_length(self):
""" Get sek_payload_encryption_key_length value.
Notes:
Group Key Sek Payload Encryption Key Length (read only)
This attribute is named `SEKPayloadEncryptionKeyLength` in VSD API.
"""
return self._sek_payload_encryption_key_length
@sek_payload_encryption_key_length.setter
def sek_payload_encryption_key_length(self, value):
""" Set sek_payload_encryption_key_length value.
Notes:
Group Key Sek Payload Encryption Key Length (read only)
This attribute is named `SEKPayloadEncryptionKeyLength` in VSD API.
"""
self._sek_payload_encryption_key_length = value
@property
def sek_payload_signing_algorithm(self):
""" Get sek_payload_signing_algorithm value.
Notes:
Group Key SEK Payload Signature Algorithm.
This attribute is named `SEKPayloadSigningAlgorithm` in VSD API.
"""
return self._sek_payload_signing_algorithm
@sek_payload_signing_algorithm.setter
def sek_payload_signing_algorithm(self, value):
""" Set sek_payload_signing_algorithm value.
Notes:
Group Key SEK Payload Signature Algorithm.
This attribute is named `SEKPayloadSigningAlgorithm` in VSD API.
"""
self._sek_payload_signing_algorithm = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Encryption Profile
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Encryption Profile
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def seed_generation_interval(self):
""" Get seed_generation_interval value.
Notes:
Group Key SEED Generation Interval in Seconds.
This attribute is named `seedGenerationInterval` in VSD API.
"""
return self._seed_generation_interval
@seed_generation_interval.setter
def seed_generation_interval(self, value):
""" Set seed_generation_interval value.
Notes:
Group Key SEED Generation Interval in Seconds.
This attribute is named `seedGenerationInterval` in VSD API.
"""
self._seed_generation_interval = value
@property
def seed_lifetime(self):
""" Get seed_lifetime value.
Notes:
Group Key SEED Lifetime in Seconds. Min=1, Max=86400
This attribute is named `seedLifetime` in VSD API.
"""
return self._seed_lifetime
@seed_lifetime.setter
def seed_lifetime(self, value):
""" Set seed_lifetime value.
Notes:
Group Key SEED Lifetime in Seconds. Min=1, Max=86400
This attribute is named `seedLifetime` in VSD API.
"""
self._seed_lifetime = value
@property
def seed_payload_authentication_algorithm(self):
""" Get seed_payload_authentication_algorithm value.
Notes:
Group Key SEK Payload Signature Algorithm.
This attribute is named `seedPayloadAuthenticationAlgorithm` in VSD API.
"""
return self._seed_payload_authentication_algorithm
@seed_payload_authentication_algorithm.setter
def seed_payload_authentication_algorithm(self, value):
""" Set seed_payload_authentication_algorithm value.
Notes:
Group Key SEK Payload Signature Algorithm.
This attribute is named `seedPayloadAuthenticationAlgorithm` in VSD API.
"""
self._seed_payload_authentication_algorithm = value
@property
def seed_payload_authentication_bc_algorithm(self):
""" Get seed_payload_authentication_bc_algorithm value.
Notes:
Group Key Seed Payload Authentication Algorithm (read only)
This attribute is named `seedPayloadAuthenticationBCAlgorithm` in VSD API.
"""
return self._seed_payload_authentication_bc_algorithm
@seed_payload_authentication_bc_algorithm.setter
def seed_payload_authentication_bc_algorithm(self, value):
""" Set seed_payload_authentication_bc_algorithm value.
Notes:
Group Key Seed Payload Authentication Algorithm (read only)
This attribute is named `seedPayloadAuthenticationBCAlgorithm` in VSD API.
"""
self._seed_payload_authentication_bc_algorithm = value
@property
def seed_payload_authentication_key_length(self):
""" Get seed_payload_authentication_key_length value.
Notes:
Group Key Seed Payload Authentication Key Length (read only)
This attribute is named `seedPayloadAuthenticationKeyLength` in VSD API.
"""
return self._seed_payload_authentication_key_length
@seed_payload_authentication_key_length.setter
def seed_payload_authentication_key_length(self, value):
""" Set seed_payload_authentication_key_length value.
Notes:
Group Key Seed Payload Authentication Key Length (read only)
This attribute is named `seedPayloadAuthenticationKeyLength` in VSD API.
"""
self._seed_payload_authentication_key_length = value
@property
def seed_payload_encryption_algorithm(self):
""" Get seed_payload_encryption_algorithm value.
Notes:
Group Key SEED Payload Encryption Algorithm.
This attribute is named `seedPayloadEncryptionAlgorithm` in VSD API.
"""
return self._seed_payload_encryption_algorithm
@seed_payload_encryption_algorithm.setter
def seed_payload_encryption_algorithm(self, value):
""" Set seed_payload_encryption_algorithm value.
Notes:
Group Key SEED Payload Encryption Algorithm.
This attribute is named `seedPayloadEncryptionAlgorithm` in VSD API.
"""
self._seed_payload_encryption_algorithm = value
@property
def seed_payload_encryption_bc_algorithm(self):
""" Get seed_payload_encryption_bc_algorithm value.
Notes:
Group Key Seed Payload Encryption Algorithm (read only)
This attribute is named `seedPayloadEncryptionBCAlgorithm` in VSD API.
"""
return self._seed_payload_encryption_bc_algorithm
@seed_payload_encryption_bc_algorithm.setter
def seed_payload_encryption_bc_algorithm(self, value):
""" Set seed_payload_encryption_bc_algorithm value.
Notes:
Group Key Seed Payload Encryption Algorithm (read only)
This attribute is named `seedPayloadEncryptionBCAlgorithm` in VSD API.
"""
self._seed_payload_encryption_bc_algorithm = value
@property
def seed_payload_encryption_key_length(self):
""" Get seed_payload_encryption_key_length value.
Notes:
Group Key Seed Payload Encryption Key Length (read only)
This attribute is named `seedPayloadEncryptionKeyLength` in VSD API.
"""
return self._seed_payload_encryption_key_length
@seed_payload_encryption_key_length.setter
def seed_payload_encryption_key_length(self, value):
""" Set seed_payload_encryption_key_length value.
Notes:
Group Key Seed Payload Encryption Key Length (read only)
This attribute is named `seedPayloadEncryptionKeyLength` in VSD API.
"""
self._seed_payload_encryption_key_length = value
@property
def seed_payload_signing_algorithm(self):
""" Get seed_payload_signing_algorithm value.
Notes:
Group Key Seed Payload Signature Algorithm.
This attribute is named `seedPayloadSigningAlgorithm` in VSD API.
"""
return self._seed_payload_signing_algorithm
@seed_payload_signing_algorithm.setter
def seed_payload_signing_algorithm(self, value):
""" Set seed_payload_signing_algorithm value.
Notes:
Group Key Seed Payload Signature Algorithm.
This attribute is named `seedPayloadSigningAlgorithm` in VSD API.
"""
self._seed_payload_signing_algorithm = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Profile instance created.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Profile instance created.
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def traffic_authentication_algorithm(self):
""" Get traffic_authentication_algorithm value.
Notes:
Group Key traffic Authentication Algorithm. Possible values are HMAC_SHA1, HMAC_SHA256, HMAC_SHA384, HMAC_SHA512, HMAC_MD5, .
This attribute is named `trafficAuthenticationAlgorithm` in VSD API.
"""
return self._traffic_authentication_algorithm
@traffic_authentication_algorithm.setter
def traffic_authentication_algorithm(self, value):
""" Set traffic_authentication_algorithm value.
Notes:
Group Key traffic Authentication Algorithm. Possible values are HMAC_SHA1, HMAC_SHA256, HMAC_SHA384, HMAC_SHA512, HMAC_MD5, .
This attribute is named `trafficAuthenticationAlgorithm` in VSD API.
"""
self._traffic_authentication_algorithm = value
@property
def traffic_encryption_algorithm(self):
""" Get traffic_encryption_algorithm value.
Notes:
Group Key traffic Encryption Algorithm. Possible values are AES_128_CBC, AES_192_CBC, AES_256_CBC, TRIPLE_DES_CBC, .
This attribute is named `trafficEncryptionAlgorithm` in VSD API.
"""
return self._traffic_encryption_algorithm
@traffic_encryption_algorithm.setter
def traffic_encryption_algorithm(self, value):
""" Set traffic_encryption_algorithm value.
Notes:
Group Key traffic Encryption Algorithm. Possible values are AES_128_CBC, AES_192_CBC, AES_256_CBC, TRIPLE_DES_CBC, .
This attribute is named `trafficEncryptionAlgorithm` in VSD API.
"""
self._traffic_encryption_algorithm = value
@property
def traffic_encryption_key_lifetime(self):
""" Get traffic_encryption_key_lifetime value.
Notes:
Group Key Traffic Encryption Key Lifetime in Seconds. Min=1, Max=86400
This attribute is named `trafficEncryptionKeyLifetime` in VSD API.
"""
return self._traffic_encryption_key_lifetime
@traffic_encryption_key_lifetime.setter
def traffic_encryption_key_lifetime(self, value):
""" Set traffic_encryption_key_lifetime value.
Notes:
Group Key Traffic Encryption Key Lifetime in Seconds. Min=1, Max=86400
This attribute is named `trafficEncryptionKeyLifetime` in VSD API.
"""
self._traffic_encryption_key_lifetime = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUGroupKeyEncryptionProfile
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA1
var CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA256
var CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA512
var CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_128_CBC
var CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_256_CBC
var CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC
var CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA
var CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA
var CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA
var CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA
var CONST_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA
var CONST_SEK_PAYLOAD_ENCRYPTION_ALGORITHM_RSA_1024
var CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA
var CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA
var CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA
var CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA
var CONST_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA
var CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_MD5
var CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA1
var CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA256
var CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA384
var CONST_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA512
var CONST_TRAFFIC_ENCRYPTION_ALGORITHM_AES_128_CBC
var CONST_TRAFFIC_ENCRYPTION_ALGORITHM_AES_192_CBC
var CONST_TRAFFIC_ENCRYPTION_ALGORITHM_AES_256_CBC
var CONST_TRAFFIC_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Profile instance created.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Encryption Profile
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var seed_generation_interval
Get seed_generation_interval value.
Notes: Group Key SEED Generation Interval in Seconds.
This attribute is named `seedGenerationInterval` in VSD API.
var seed_lifetime
Get seed_lifetime value.
Notes: Group Key SEED Lifetime in Seconds. Min=1, Max=86400
This attribute is named `seedLifetime` in VSD API.
var seed_payload_authentication_algorithm
Get seed_payload_authentication_algorithm value.
Notes: Group Key SEK Payload Signature Algorithm.
This attribute is named `seedPayloadAuthenticationAlgorithm` in VSD API.
var seed_payload_authentication_bc_algorithm
Get seed_payload_authentication_bc_algorithm value.
Notes: Group Key Seed Payload Authentication Algorithm (read only)
This attribute is named `seedPayloadAuthenticationBCAlgorithm` in VSD API.
var seed_payload_authentication_key_length
Get seed_payload_authentication_key_length value.
Notes: Group Key Seed Payload Authentication Key Length (read only)
This attribute is named `seedPayloadAuthenticationKeyLength` in VSD API.
var seed_payload_encryption_algorithm
Get seed_payload_encryption_algorithm value.
Notes: Group Key SEED Payload Encryption Algorithm.
This attribute is named `seedPayloadEncryptionAlgorithm` in VSD API.
var seed_payload_encryption_bc_algorithm
Get seed_payload_encryption_bc_algorithm value.
Notes: Group Key Seed Payload Encryption Algorithm (read only)
This attribute is named `seedPayloadEncryptionBCAlgorithm` in VSD API.
var seed_payload_encryption_key_length
Get seed_payload_encryption_key_length value.
Notes: Group Key Seed Payload Encryption Key Length (read only)
This attribute is named `seedPayloadEncryptionKeyLength` in VSD API.
var seed_payload_signing_algorithm
Get seed_payload_signing_algorithm value.
Notes: Group Key Seed Payload Signature Algorithm.
This attribute is named `seedPayloadSigningAlgorithm` in VSD API.
var sek_generation_interval
Get sek_generation_interval value.
Notes: Group Key SEK Generation Interval in Seconds. Min=1, Max=86400
This attribute is named `SEKGenerationInterval` in VSD API.
var sek_lifetime
Get sek_lifetime value.
Notes: Group Key SEK Lifetime in Seconds. Min=1, Max=86400
This attribute is named `SEKLifetime` in VSD API.
var sek_payload_encryption_algorithm
Get sek_payload_encryption_algorithm value.
Notes: Group Key SEK Payload Encryption Algorithm.
This attribute is named `SEKPayloadEncryptionAlgorithm` in VSD API.
var sek_payload_encryption_bc_algorithm
Get sek_payload_encryption_bc_algorithm value.
Notes: Group Key Sek Payload Encryption BC Algorithm (read only)
This attribute is named `SEKPayloadEncryptionBCAlgorithm` in VSD API.
var sek_payload_encryption_key_length
Get sek_payload_encryption_key_length value.
Notes: Group Key Sek Payload Encryption Key Length (read only)
This attribute is named `SEKPayloadEncryptionKeyLength` in VSD API.
var sek_payload_signing_algorithm
Get sek_payload_signing_algorithm value.
Notes: Group Key SEK Payload Signature Algorithm.
This attribute is named `SEKPayloadSigningAlgorithm` in VSD API.
var traffic_authentication_algorithm
Get traffic_authentication_algorithm value.
Notes: Group Key traffic Authentication Algorithm. Possible values are HMAC_SHA1, HMAC_SHA256, HMAC_SHA384, HMAC_SHA512, HMAC_MD5, .
This attribute is named `trafficAuthenticationAlgorithm` in VSD API.
var traffic_encryption_algorithm
Get traffic_encryption_algorithm value.
Notes: Group Key traffic Encryption Algorithm. Possible values are AES_128_CBC, AES_192_CBC, AES_256_CBC, TRIPLE_DES_CBC, .
This attribute is named `trafficEncryptionAlgorithm` in VSD API.
var traffic_encryption_key_lifetime
Get traffic_encryption_key_lifetime value.
Notes: Group Key Traffic Encryption Key Lifetime in Seconds. Min=1, Max=86400
This attribute is named `trafficEncryptionKeyLifetime` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a GroupKeyEncryptionProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> groupkeyencryptionprofile = NUGroupKeyEncryptionProfile(id=u'xxxx-xxx-xxx-xxx', name=u'GroupKeyEncryptionProfile') >>> groupkeyencryptionprofile = NUGroupKeyEncryptionProfile(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a GroupKeyEncryptionProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> groupkeyencryptionprofile = NUGroupKeyEncryptionProfile(id=u'xxxx-xxx-xxx-xxx', name=u'GroupKeyEncryptionProfile')
>>> groupkeyencryptionprofile = NUGroupKeyEncryptionProfile(data=my_dict)
"""
super(NUGroupKeyEncryptionProfile, self).__init__()
# Read/Write Attributes
self._sek_generation_interval = None
self._sek_lifetime = None
self._sek_payload_encryption_algorithm = None
self._sek_payload_encryption_bc_algorithm = None
self._sek_payload_encryption_key_length = None
self._sek_payload_signing_algorithm = None
self._name = None
self._last_updated_by = None
self._seed_generation_interval = None
self._seed_lifetime = None
self._seed_payload_authentication_algorithm = None
self._seed_payload_authentication_bc_algorithm = None
self._seed_payload_authentication_key_length = None
self._seed_payload_encryption_algorithm = None
self._seed_payload_encryption_bc_algorithm = None
self._seed_payload_encryption_key_length = None
self._seed_payload_signing_algorithm = None
self._description = None
self._entity_scope = None
self._traffic_authentication_algorithm = None
self._traffic_encryption_algorithm = None
self._traffic_encryption_key_lifetime = None
self._external_id = None
self.expose_attribute(local_name="sek_generation_interval", remote_name="SEKGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_lifetime", remote_name="SEKLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_payload_encryption_algorithm", remote_name="SEKPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'RSA_1024'])
self.expose_attribute(local_name="sek_payload_encryption_bc_algorithm", remote_name="SEKPayloadEncryptionBCAlgorithm", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_payload_encryption_key_length", remote_name="SEKPayloadEncryptionKeyLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sek_payload_signing_algorithm", remote_name="SEKPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_generation_interval", remote_name="seedGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_lifetime", remote_name="seedLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_authentication_algorithm", remote_name="seedPayloadAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA512'])
self.expose_attribute(local_name="seed_payload_authentication_bc_algorithm", remote_name="seedPayloadAuthenticationBCAlgorithm", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_authentication_key_length", remote_name="seedPayloadAuthenticationKeyLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_encryption_algorithm", remote_name="seedPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="seed_payload_encryption_bc_algorithm", remote_name="seedPayloadEncryptionBCAlgorithm", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_encryption_key_length", remote_name="seedPayloadEncryptionKeyLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_signing_algorithm", remote_name="seedPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="traffic_authentication_algorithm", remote_name="trafficAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_MD5', u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA384', u'HMAC_SHA512'])
self.expose_attribute(local_name="traffic_encryption_algorithm", remote_name="trafficEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_192_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="traffic_encryption_key_lifetime", remote_name="trafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUHSC
Represents a HSC in the VSD
Notes: System Monitoring details for hardware service controllers.
class NUHSC(NURESTObject):
""" Represents a HSC in the VSD
Notes:
System Monitoring details for hardware service controllers.
"""
__rest_name__ = "hsc"
__resource_name__ = "hscs"
## Constants
CONST_TYPE_VSG = "VSG"
CONST_STATUS_DOWN = "DOWN"
CONST_TYPE_VSA = "VSA"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_TYPE_NONE = "NONE"
CONST_TYPE_DC7X50 = "DC7X50"
CONST_STATUS_UP = "UP"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_STATUS_ADMIN_DOWN = "ADMIN_DOWN"
def __init__(self, **kwargs):
""" Initializes a HSC instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> hsc = NUHSC(id=u'xxxx-xxx-xxx-xxx', name=u'HSC')
>>> hsc = NUHSC(data=my_dict)
"""
super(NUHSC, self).__init__()
# Read/Write Attributes
self._name = None
self._management_ip = None
self._last_state_change = None
self._last_updated_by = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._description = None
self._messages = None
self._disks = None
self._already_marked_for_unavailable = None
self._unavailable_timestamp = None
self._entity_scope = None
self._location = None
self._model = None
self._product_version = None
self._vsds = None
self._status = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="already_marked_for_unavailable", remote_name="alreadyMarkedForUnavailable", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="unavailable_timestamp", remote_name="unavailableTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="model", remote_name="model", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsds", remote_name="vsds", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'NONE', u'VSA', u'VSG'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bgp_peers = NUBGPPeersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.monitoring_ports = NUMonitoringPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Identifies the entity with a name.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Identifies the entity with a name.
"""
self._name = value
@property
def management_ip(self):
""" Get management_ip value.
Notes:
The management IP of the VSC/HSC entity
This attribute is named `managementIP` in VSD API.
"""
return self._management_ip
@management_ip.setter
def management_ip(self, value):
""" Set management_ip value.
Notes:
The management IP of the VSC/HSC entity
This attribute is named `managementIP` in VSD API.
"""
self._management_ip = value
@property
def last_state_change(self):
""" Get last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
return self._last_state_change
@last_state_change.setter
def last_state_change(self, value):
""" Set last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
self._last_state_change = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
The IP of the VRS entity
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
The IP of the VRS entity
"""
self._address = value
@property
def peak_cpuusage(self):
""" Get peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
return self._peak_cpuusage
@peak_cpuusage.setter
def peak_cpuusage(self, value):
""" Set peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
self._peak_cpuusage = value
@property
def peak_memory_usage(self):
""" Get peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
return self._peak_memory_usage
@peak_memory_usage.setter
def peak_memory_usage(self, value):
""" Set peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
self._peak_memory_usage = value
@property
def description(self):
""" Get description value.
Notes:
Description of the entity.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the entity.
"""
self._description = value
@property
def messages(self):
""" Get messages value.
Notes:
An array of degraded messages.
"""
return self._messages
@messages.setter
def messages(self, value):
""" Set messages value.
Notes:
An array of degraded messages.
"""
self._messages = value
@property
def disks(self):
""" Get disks value.
Notes:
Set of disk usage details.
"""
return self._disks
@disks.setter
def disks(self, value):
""" Set disks value.
Notes:
Set of disk usage details.
"""
self._disks = value
@property
def already_marked_for_unavailable(self):
""" Get already_marked_for_unavailable value.
Notes:
Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
"""
return self._already_marked_for_unavailable
@already_marked_for_unavailable.setter
def already_marked_for_unavailable(self, value):
""" Set already_marked_for_unavailable value.
Notes:
Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
"""
self._already_marked_for_unavailable = value
@property
def unavailable_timestamp(self):
""" Get unavailable_timestamp value.
Notes:
The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
"""
return self._unavailable_timestamp
@unavailable_timestamp.setter
def unavailable_timestamp(self, value):
""" Set unavailable_timestamp value.
Notes:
The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
"""
self._unavailable_timestamp = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location(self):
""" Get location value.
Notes:
Identifies the entity to be associated with a location.
"""
return self._location
@location.setter
def location(self, value):
""" Set location value.
Notes:
Identifies the entity to be associated with a location.
"""
self._location = value
@property
def model(self):
""" Get model value.
Notes:
The model of the hardware service controller
"""
return self._model
@model.setter
def model(self, value):
""" Set model value.
Notes:
The model of the hardware service controller
"""
self._model = value
@property
def product_version(self):
""" Get product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
return self._product_version
@product_version.setter
def product_version(self, value):
""" Set product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
self._product_version = value
@property
def vsds(self):
""" Get vsds value.
Notes:
A collection of VSD id(s) which are identified by this controller.
"""
return self._vsds
@vsds.setter
def vsds(self, value):
""" Set vsds value.
Notes:
A collection of VSD id(s) which are identified by this controller.
"""
self._vsds = value
@property
def status(self):
""" Get status value.
Notes:
Computed status of the entity. Possible values are UP, DOWN, ADMIN_DOWN, .
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Computed status of the entity. Possible values are UP, DOWN, ADMIN_DOWN, .
"""
self._status = value
@property
def current_cpuusage(self):
""" Get current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
return self._current_cpuusage
@current_cpuusage.setter
def current_cpuusage(self, value):
""" Set current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
self._current_cpuusage = value
@property
def current_memory_usage(self):
""" Get current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
return self._current_memory_usage
@current_memory_usage.setter
def current_memory_usage(self, value):
""" Set current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
self._current_memory_usage = value
@property
def average_cpuusage(self):
""" Get average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
return self._average_cpuusage
@average_cpuusage.setter
def average_cpuusage(self, value):
""" Set average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
self._average_cpuusage = value
@property
def average_memory_usage(self):
""" Get average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
return self._average_memory_usage
@average_memory_usage.setter
def average_memory_usage(self, value):
""" Set average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
self._average_memory_usage = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
The type of the hardware service controller.
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
The type of the hardware service controller.
"""
self._type = value
Ancestors (in MRO)
- NUHSC
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_STATUS_ADMIN_DOWN
var CONST_STATUS_DOWN
var CONST_STATUS_UP
var CONST_TYPE_DC7X50
var CONST_TYPE_NONE
var CONST_TYPE_VSA
var CONST_TYPE_VSG
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: The IP of the VRS entity
var alarms
Get already_marked_for_unavailable value.
Notes: Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
var average_cpuusage
Get average_cpuusage value.
Notes: Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
var average_memory_usage
Get average_memory_usage value.
Notes: Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
var bgp_peers
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var current_cpuusage
Get current_cpuusage value.
Notes: Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
var current_memory_usage
Get current_memory_usage value.
Notes: Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
var description
Get description value.
Notes: Description of the entity.
var disks
Get disks value.
Notes: Set of disk usage details.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_state_change
Get last_state_change value.
Notes: Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location
Get location value.
Notes: Identifies the entity to be associated with a location.
var management_ip
Get management_ip value.
Notes: The management IP of the VSC/HSC entity
This attribute is named `managementIP` in VSD API.
var messages
Get messages value.
Notes: An array of degraded messages.
var metadatas
var model
Get model value.
Notes: The model of the hardware service controller
var monitoring_ports
var name
Get name value.
Notes: Identifies the entity with a name.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var peak_cpuusage
Get peak_cpuusage value.
Notes: Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
var peak_memory_usage
Get peak_memory_usage value.
Notes: Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
var product_version
Get product_version value.
Notes: Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
var status
Get status value.
Notes: Computed status of the entity. Possible values are UP, DOWN, ADMIN_DOWN, .
var type
Get type value.
Notes: The type of the hardware service controller.
Get unavailable_timestamp value.
Notes: The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
var vrss
var vsds
Get vsds value.
Notes: A collection of VSD id(s) which are identified by this controller.
Methods
def __init__(
self, **kwargs)
Initializes a HSC instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> hsc = NUHSC(id=u'xxxx-xxx-xxx-xxx', name=u'HSC') >>> hsc = NUHSC(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a HSC instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> hsc = NUHSC(id=u'xxxx-xxx-xxx-xxx', name=u'HSC')
>>> hsc = NUHSC(data=my_dict)
"""
super(NUHSC, self).__init__()
# Read/Write Attributes
self._name = None
self._management_ip = None
self._last_state_change = None
self._last_updated_by = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._description = None
self._messages = None
self._disks = None
self._already_marked_for_unavailable = None
self._unavailable_timestamp = None
self._entity_scope = None
self._location = None
self._model = None
self._product_version = None
self._vsds = None
self._status = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="already_marked_for_unavailable", remote_name="alreadyMarkedForUnavailable", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="unavailable_timestamp", remote_name="unavailableTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="model", remote_name="model", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsds", remote_name="vsds", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'NONE', u'VSA', u'VSG'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bgp_peers = NUBGPPeersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.monitoring_ports = NUMonitoringPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUHostInterface
Represents a HostInterface in the VSD
Notes: Provides information for each host interface.
class NUHostInterface(NURESTObject):
""" Represents a HostInterface in the VSD
Notes:
Provides information for each host interface.
"""
__rest_name__ = "hostinterface"
__resource_name__ = "hostinterfaces"
## Constants
CONST_ATTACHED_NETWORK_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ATTACHED_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a HostInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> hostinterface = NUHostInterface(id=u'xxxx-xxx-xxx-xxx', name=u'HostInterface')
>>> hostinterface = NUHostInterface(data=my_dict)
"""
super(NUHostInterface, self).__init__()
# Read/Write Attributes
self._mac = None
self._ip_address = None
self._vport_id = None
self._vport_name = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._netmask = None
self._network_name = None
self._tier_id = None
self._entity_scope = None
self._policy_decision_id = None
self._domain_id = None
self._domain_name = None
self._zone_id = None
self._zone_name = None
self._associated_floating_ip_address = None
self._attached_network_id = None
self._attached_network_type = None
self._external_id = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="IPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_id", remote_name="VPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tier_id", remote_name="tierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_decision_id", remote_name="policyDecisionID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_name", remote_name="zoneName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_address", remote_name="associatedFloatingIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_id", remote_name="attachedNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'L2DOMAIN', u'SUBNET'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_decisions = NUPolicyDecisionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def mac(self):
""" Get mac value.
Notes:
MAC address of the interface, cannot be modified after creation.
This attribute is named `MAC` in VSD API.
"""
return self._mac
@mac.setter
def mac(self, value):
""" Set mac value.
Notes:
MAC address of the interface, cannot be modified after creation.
This attribute is named `MAC` in VSD API.
"""
self._mac = value
@property
def ip_address(self):
""" Get ip_address value.
Notes:
IP address of the interface
This attribute is named `IPAddress` in VSD API.
"""
return self._ip_address
@ip_address.setter
def ip_address(self, value):
""" Set ip_address value.
Notes:
IP address of the interface
This attribute is named `IPAddress` in VSD API.
"""
self._ip_address = value
@property
def vport_id(self):
""" Get vport_id value.
Notes:
ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
"""
return self._vport_id
@vport_id.setter
def vport_id(self, value):
""" Set vport_id value.
Notes:
ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
"""
self._vport_id = value
@property
def vport_name(self):
""" Get vport_name value.
Notes:
Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
"""
return self._vport_name
@vport_name.setter
def vport_name(self, value):
""" Set vport_name value.
Notes:
Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
"""
self._vport_name = value
@property
def name(self):
""" Get name value.
Notes:
Device name associated with this interface
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Device name associated with this interface
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
Gateway of the subnet that the VM is connected to
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
Gateway of the subnet that the VM is connected to
"""
self._gateway = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet that the VM is attached to
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet that the VM is attached to
"""
self._netmask = value
@property
def network_name(self):
""" Get network_name value.
Notes:
Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
"""
return self._network_name
@network_name.setter
def network_name(self, value):
""" Set network_name value.
Notes:
Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
"""
self._network_name = value
@property
def tier_id(self):
""" Get tier_id value.
Notes:
ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
"""
return self._tier_id
@tier_id.setter
def tier_id(self, value):
""" Set tier_id value.
Notes:
ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
"""
self._tier_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_decision_id(self):
""" Get policy_decision_id value.
Notes:
The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
"""
return self._policy_decision_id
@policy_decision_id.setter
def policy_decision_id(self, value):
""" Set policy_decision_id value.
Notes:
The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
"""
self._policy_decision_id = value
@property
def domain_id(self):
""" Get domain_id value.
Notes:
ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
"""
return self._domain_id
@domain_id.setter
def domain_id(self, value):
""" Set domain_id value.
Notes:
ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
"""
self._domain_id = value
@property
def domain_name(self):
""" Get domain_name value.
Notes:
Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
"""
return self._domain_name
@domain_name.setter
def domain_name(self, value):
""" Set domain_name value.
Notes:
Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
"""
self._domain_name = value
@property
def zone_id(self):
""" Get zone_id value.
Notes:
ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
"""
return self._zone_id
@zone_id.setter
def zone_id(self, value):
""" Set zone_id value.
Notes:
ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
"""
self._zone_id = value
@property
def zone_name(self):
""" Get zone_name value.
Notes:
Name of the zone that the VM is attached to
This attribute is named `zoneName` in VSD API.
"""
return self._zone_name
@zone_name.setter
def zone_name(self, value):
""" Set zone_name value.
Notes:
Name of the zone that the VM is attached to
This attribute is named `zoneName` in VSD API.
"""
self._zone_name = value
@property
def associated_floating_ip_address(self):
""" Get associated_floating_ip_address value.
Notes:
Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
"""
return self._associated_floating_ip_address
@associated_floating_ip_address.setter
def associated_floating_ip_address(self, value):
""" Set associated_floating_ip_address value.
Notes:
Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
"""
self._associated_floating_ip_address = value
@property
def attached_network_id(self):
""" Get attached_network_id value.
Notes:
ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
"""
return self._attached_network_id
@attached_network_id.setter
def attached_network_id(self, value):
""" Set attached_network_id value.
Notes:
ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
"""
self._attached_network_id = value
@property
def attached_network_type(self):
""" Get attached_network_type value.
Notes:
l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
"""
return self._attached_network_type
@attached_network_type.setter
def attached_network_type(self, value):
""" Set attached_network_type value.
Notes:
l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
"""
self._attached_network_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUHostInterface
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ATTACHED_NETWORK_TYPE_L2DOMAIN
var CONST_ATTACHED_NETWORK_TYPE_SUBNET
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_floating_ip_address
Get associated_floating_ip_address value.
Notes: Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
var attached_network_id
Get attached_network_id value.
Notes: ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
var attached_network_type
Get attached_network_type value.
Notes: l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var dhcp_options
var domain_id
Get domain_id value.
Notes: ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
var domain_name
Get domain_name value.
Notes: Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: Gateway of the subnet that the VM is connected to
var global_metadatas
var id
Get object id
var ip_address
Get ip_address value.
Notes: IP address of the interface
This attribute is named `IPAddress` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var mac
Get mac value.
Notes: MAC address of the interface, cannot be modified after creation.
This attribute is named `MAC` in VSD API.
var metadatas
var multi_cast_channel_maps
var name
Get name value.
Notes: Device name associated with this interface
var netmask
Get netmask value.
Notes: Netmask of the subnet that the VM is attached to
var network_name
Get network_name value.
Notes: Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_decision_id
Get policy_decision_id value.
Notes: The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
var policy_decisions
var policy_groups
var qoss
var redirection_targets
var static_routes
var statistics
var tcas
var tier_id
Get tier_id value.
Notes: ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
var vport_id
Get vport_id value.
Notes: ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
var vport_name
Get vport_name value.
Notes: Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
var zone_id
Get zone_id value.
Notes: ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
var zone_name
Get zone_name value.
Notes: Name of the zone that the VM is attached to
This attribute is named `zoneName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a HostInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> hostinterface = NUHostInterface(id=u'xxxx-xxx-xxx-xxx', name=u'HostInterface') >>> hostinterface = NUHostInterface(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a HostInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> hostinterface = NUHostInterface(id=u'xxxx-xxx-xxx-xxx', name=u'HostInterface')
>>> hostinterface = NUHostInterface(data=my_dict)
"""
super(NUHostInterface, self).__init__()
# Read/Write Attributes
self._mac = None
self._ip_address = None
self._vport_id = None
self._vport_name = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._netmask = None
self._network_name = None
self._tier_id = None
self._entity_scope = None
self._policy_decision_id = None
self._domain_id = None
self._domain_name = None
self._zone_id = None
self._zone_name = None
self._associated_floating_ip_address = None
self._attached_network_id = None
self._attached_network_type = None
self._external_id = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="IPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_id", remote_name="VPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tier_id", remote_name="tierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_decision_id", remote_name="policyDecisionID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_name", remote_name="zoneName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_address", remote_name="associatedFloatingIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_id", remote_name="attachedNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'L2DOMAIN', u'SUBNET'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_decisions = NUPolicyDecisionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUIPReservation
Represents a IPReservation in the VSD
Notes: This is the definition of a IP Bindings associated with in a Network.
class NUIPReservation(NURESTObject):
""" Represents a IPReservation in the VSD
Notes:
This is the definition of a IP Bindings associated with in a Network.
"""
__rest_name__ = "ipreservation"
__resource_name__ = "ipreservations"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a IPReservation instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ipreservation = NUIPReservation(id=u'xxxx-xxx-xxx-xxx', name=u'IPReservation')
>>> ipreservation = NUIPReservation(data=my_dict)
"""
super(NUIPReservation, self).__init__()
# Read/Write Attributes
self._mac = None
self._ip_address = None
self._last_updated_by = None
self._entity_scope = None
self._external_id = None
self._dynamic_allocation_enabled = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="IPAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="dynamic_allocation_enabled", remote_name="dynamicAllocationEnabled", attribute_type=bool, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def mac(self):
""" Get mac value.
Notes:
MAC Address
This attribute is named `MAC` in VSD API.
"""
return self._mac
@mac.setter
def mac(self, value):
""" Set mac value.
Notes:
MAC Address
This attribute is named `MAC` in VSD API.
"""
self._mac = value
@property
def ip_address(self):
""" Get ip_address value.
Notes:
Static IP Address
This attribute is named `IPAddress` in VSD API.
"""
return self._ip_address
@ip_address.setter
def ip_address(self, value):
""" Set ip_address value.
Notes:
Static IP Address
This attribute is named `IPAddress` in VSD API.
"""
self._ip_address = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def dynamic_allocation_enabled(self):
""" Get dynamic_allocation_enabled value.
Notes:
Binding is static or dynamic
This attribute is named `dynamicAllocationEnabled` in VSD API.
"""
return self._dynamic_allocation_enabled
@dynamic_allocation_enabled.setter
def dynamic_allocation_enabled(self, value):
""" Set dynamic_allocation_enabled value.
Notes:
Binding is static or dynamic
This attribute is named `dynamicAllocationEnabled` in VSD API.
"""
self._dynamic_allocation_enabled = value
Ancestors (in MRO)
- NUIPReservation
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var dynamic_allocation_enabled
Get dynamic_allocation_enabled value.
Notes: Binding is static or dynamic
This attribute is named `dynamicAllocationEnabled` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ip_address
Get ip_address value.
Notes: Static IP Address
This attribute is named `IPAddress` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var mac
Get mac value.
Notes: MAC Address
This attribute is named `MAC` in VSD API.
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a IPReservation instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ipreservation = NUIPReservation(id=u'xxxx-xxx-xxx-xxx', name=u'IPReservation') >>> ipreservation = NUIPReservation(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a IPReservation instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ipreservation = NUIPReservation(id=u'xxxx-xxx-xxx-xxx', name=u'IPReservation')
>>> ipreservation = NUIPReservation(data=my_dict)
"""
super(NUIPReservation, self).__init__()
# Read/Write Attributes
self._mac = None
self._ip_address = None
self._last_updated_by = None
self._entity_scope = None
self._external_id = None
self._dynamic_allocation_enabled = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="IPAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="dynamic_allocation_enabled", remote_name="dynamicAllocationEnabled", attribute_type=bool, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUInfrastructureConfig
Represents a InfrastructureConfig in the VSD
Notes: Represents Infrastructure Config
class NUInfrastructureConfig(NURESTObject):
""" Represents a InfrastructureConfig in the VSD
Notes:
Represents Infrastructure Config
"""
__rest_name__ = "infraconfig"
__resource_name__ = "infraconfig"
## Constants
CONST_CONFIG_STATUS_UNKNOWN = "UNKNOWN"
CONST_CONFIG_STATUS_FAILURE = "FAILURE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_CONFIG_STATUS_SUCCESS = "SUCCESS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a InfrastructureConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructureconfig = NUInfrastructureConfig(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureConfig')
>>> infrastructureconfig = NUInfrastructureConfig(data=my_dict)
"""
super(NUInfrastructureConfig, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._entity_scope = None
self._config = None
self._config_status = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="config", remote_name="config", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="config_status", remote_name="configStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILURE', u'SUCCESS', u'UNKNOWN'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def config(self):
""" Get config value.
Notes:
Infrastructure Config
"""
return self._config
@config.setter
def config(self, value):
""" Set config value.
Notes:
Infrastructure Config
"""
self._config = value
@property
def config_status(self):
""" Get config_status value.
Notes:
Status of the configuration application
This attribute is named `configStatus` in VSD API.
"""
return self._config_status
@config_status.setter
def config_status(self, value):
""" Set config_status value.
Notes:
Status of the configuration application
This attribute is named `configStatus` in VSD API.
"""
self._config_status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUInfrastructureConfig
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_CONFIG_STATUS_FAILURE
var CONST_CONFIG_STATUS_SUCCESS
var CONST_CONFIG_STATUS_UNKNOWN
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var config
Get config value.
Notes: Infrastructure Config
var config_status
Get config_status value.
Notes: Status of the configuration application
This attribute is named `configStatus` in VSD API.
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a InfrastructureConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> infrastructureconfig = NUInfrastructureConfig(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureConfig') >>> infrastructureconfig = NUInfrastructureConfig(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a InfrastructureConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructureconfig = NUInfrastructureConfig(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureConfig')
>>> infrastructureconfig = NUInfrastructureConfig(data=my_dict)
"""
super(NUInfrastructureConfig, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._entity_scope = None
self._config = None
self._config_status = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="config", remote_name="config", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="config_status", remote_name="configStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILURE', u'SUCCESS', u'UNKNOWN'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUInfrastructureGatewayProfile
Represents a InfrastructureGatewayProfile in the VSD
Notes: Represents Infrastructure Gateway Profile
class NUInfrastructureGatewayProfile(NURESTObject):
""" Represents a InfrastructureGatewayProfile in the VSD
Notes:
Represents Infrastructure Gateway Profile
"""
__rest_name__ = "infrastructuregatewayprofile"
__resource_name__ = "infrastructuregatewayprofiles"
## Constants
CONST_DEAD_TIMER_THREE_HOURS = "THREE_HOURS"
CONST_SYSTEM_SYNC_WINDOW_SIX_HOURS = "SIX_HOURS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_REMOTE_LOG_MODE_DISABLED = "DISABLED"
CONST_REMOTE_LOG_MODE_SFTP = "SFTP"
CONST_UPGRADE_ACTION_DOWNLOAD_ONLY = "DOWNLOAD_ONLY"
CONST_DEAD_TIMER_FOUR_HOURS = "FOUR_HOURS"
CONST_SYSTEM_SYNC_WINDOW_FOUR_HOURS = "FOUR_HOURS"
CONST_SYSTEM_SYNC_WINDOW_THREE_HOURS = "THREE_HOURS"
CONST_DEAD_TIMER_TEN_MINUTES = "TEN_MINUTES"
CONST_DEAD_TIMER_THIRTY_MINUTES = "THIRTY_MINUTES"
CONST_UPGRADE_ACTION_UPGRADE_AT_BOOTSTRAPPING = "UPGRADE_AT_BOOTSTRAPPING"
CONST_SYSTEM_SYNC_WINDOW_THIRTY_MINUTES = "THIRTY_MINUTES"
CONST_UPGRADE_ACTION_NONE = "NONE"
CONST_SYSTEM_SYNC_WINDOW_NONE = "NONE"
CONST_SYSTEM_SYNC_WINDOW_TWO_HOURS = "TWO_HOURS"
CONST_DEAD_TIMER_FIVE_HOURS = "FIVE_HOURS"
CONST_DEAD_TIMER_NONE = "NONE"
CONST_UPGRADE_ACTION_UPGRADE_NOW = "UPGRADE_NOW"
CONST_DEAD_TIMER_SIX_HOURS = "SIX_HOURS"
CONST_SYSTEM_SYNC_WINDOW_TEN_MINUTES = "TEN_MINUTES"
CONST_SYSTEM_SYNC_WINDOW_FIVE_HOURS = "FIVE_HOURS"
CONST_UPGRADE_ACTION_DOWNLOAD_AND_UPGRADE_AT_WINDOW = "DOWNLOAD_AND_UPGRADE_AT_WINDOW"
CONST_REMOTE_LOG_MODE_SCP = "SCP"
CONST_DEAD_TIMER_TWO_HOURS = "TWO_HOURS"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_REMOTE_LOG_MODE_RSYSLOG = "RSYSLOG"
CONST_DEAD_TIMER_ONE_HOUR = "ONE_HOUR"
CONST_SYSTEM_SYNC_WINDOW_ONE_HOUR = "ONE_HOUR"
CONST_UPGRADE_ACTION_DOWNLOAD_AND_UPGRADE_NOW = "DOWNLOAD_AND_UPGRADE_NOW"
def __init__(self, **kwargs):
""" Initializes a InfrastructureGatewayProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructuregatewayprofile = NUInfrastructureGatewayProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureGatewayProfile')
>>> infrastructuregatewayprofile = NUInfrastructureGatewayProfile(data=my_dict)
"""
super(NUInfrastructureGatewayProfile, self).__init__()
# Read/Write Attributes
self._ntp_server_key = None
self._ntp_server_key_id = None
self._name = None
self._last_updated_by = None
self._datapath_sync_timeout = None
self._dead_timer = None
self._remote_log_dir_path = None
self._remote_log_mode = None
self._remote_log_password = None
self._remote_log_server_address = None
self._remote_log_server_port = None
self._remote_log_username = None
self._description = None
self._metadata_upgrade_path = None
self._flow_eviction_threshold = None
self._enterprise_id = None
self._entity_scope = None
self._upgrade_action = None
self._proxy_dns_name = None
self._use_two_factor = None
self._stats_collector_port = None
self._external_id = None
self._system_sync_scheduler = None
self._system_sync_window = None
self.expose_attribute(local_name="ntp_server_key", remote_name="NTPServerKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server_key_id", remote_name="NTPServerKeyID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="dead_timer", remote_name="deadTimer", attribute_type=str, is_required=False, is_unique=False, choices=[u'FIVE_HOURS', u'FOUR_HOURS', u'NONE', u'ONE_HOUR', u'SIX_HOURS', u'TEN_MINUTES', u'THIRTY_MINUTES', u'THREE_HOURS', u'TWO_HOURS'])
self.expose_attribute(local_name="remote_log_dir_path", remote_name="remoteLogDirPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_mode", remote_name="remoteLogMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'RSYSLOG', u'SCP', u'SFTP'])
self.expose_attribute(local_name="remote_log_password", remote_name="remoteLogPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_server_address", remote_name="remoteLogServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_server_port", remote_name="remoteLogServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_username", remote_name="remoteLogUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_upgrade_path", remote_name="metadataUpgradePath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="upgrade_action", remote_name="upgradeAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOWNLOAD_AND_UPGRADE_AT_WINDOW', u'DOWNLOAD_AND_UPGRADE_NOW', u'DOWNLOAD_ONLY', u'NONE', u'UPGRADE_AT_BOOTSTRAPPING', u'UPGRADE_NOW'])
self.expose_attribute(local_name="proxy_dns_name", remote_name="proxyDNSName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="use_two_factor", remote_name="useTwoFactor", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_port", remote_name="statsCollectorPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_sync_scheduler", remote_name="systemSyncScheduler", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="system_sync_window", remote_name="systemSyncWindow", attribute_type=str, is_required=False, is_unique=False, choices=[u'FIVE_HOURS', u'FOUR_HOURS', u'NONE', u'ONE_HOUR', u'SIX_HOURS', u'TEN_MINUTES', u'THIRTY_MINUTES', u'THREE_HOURS', u'TWO_HOURS'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ntp_server_key(self):
""" Get ntp_server_key value.
Notes:
If set, this represents the security key for the Gateway to communicate with the NTP server (a VSC).
This attribute is named `NTPServerKey` in VSD API.
"""
return self._ntp_server_key
@ntp_server_key.setter
def ntp_server_key(self, value):
""" Set ntp_server_key value.
Notes:
If set, this represents the security key for the Gateway to communicate with the NTP server (a VSC).
This attribute is named `NTPServerKey` in VSD API.
"""
self._ntp_server_key = value
@property
def ntp_server_key_id(self):
""" Get ntp_server_key_id value.
Notes:
Correspond to the key ID on the NTP server that matches the ntpServerKey value. Valid values are from 1 to 255 as specified by SR-OS and 0 to specify unused (VSD/NSG only).
This attribute is named `NTPServerKeyID` in VSD API.
"""
return self._ntp_server_key_id
@ntp_server_key_id.setter
def ntp_server_key_id(self, value):
""" Set ntp_server_key_id value.
Notes:
Correspond to the key ID on the NTP server that matches the ntpServerKey value. Valid values are from 1 to 255 as specified by SR-OS and 0 to specify unused (VSD/NSG only).
This attribute is named `NTPServerKeyID` in VSD API.
"""
self._ntp_server_key_id = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Infrastructure Profile
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Infrastructure Profile
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def datapath_sync_timeout(self):
""" Get datapath_sync_timeout value.
Notes:
Datapath flows sync-time-interval specified in milliseconds (default: 1000)
This attribute is named `datapathSyncTimeout` in VSD API.
"""
return self._datapath_sync_timeout
@datapath_sync_timeout.setter
def datapath_sync_timeout(self, value):
""" Set datapath_sync_timeout value.
Notes:
Datapath flows sync-time-interval specified in milliseconds (default: 1000)
This attribute is named `datapathSyncTimeout` in VSD API.
"""
self._datapath_sync_timeout = value
@property
def dead_timer(self):
""" Get dead_timer value.
Notes:
Time, in seconds, allowed for a Gateway to be inactive before the VSD revokes its certificates and marks it as untrusted.
This attribute is named `deadTimer` in VSD API.
"""
return self._dead_timer
@dead_timer.setter
def dead_timer(self, value):
""" Set dead_timer value.
Notes:
Time, in seconds, allowed for a Gateway to be inactive before the VSD revokes its certificates and marks it as untrusted.
This attribute is named `deadTimer` in VSD API.
"""
self._dead_timer = value
@property
def remote_log_dir_path(self):
""" Get remote_log_dir_path value.
Notes:
Path on the remote log server where the logs generated by the NSG are to be stored. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogDirPath` in VSD API.
"""
return self._remote_log_dir_path
@remote_log_dir_path.setter
def remote_log_dir_path(self, value):
""" Set remote_log_dir_path value.
Notes:
Path on the remote log server where the logs generated by the NSG are to be stored. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogDirPath` in VSD API.
"""
self._remote_log_dir_path = value
@property
def remote_log_mode(self):
""" Get remote_log_mode value.
Notes:
Type of Log Server for system logs generated by Gateways associated with this Infrastructure Profile.
This attribute is named `remoteLogMode` in VSD API.
"""
return self._remote_log_mode
@remote_log_mode.setter
def remote_log_mode(self, value):
""" Set remote_log_mode value.
Notes:
Type of Log Server for system logs generated by Gateways associated with this Infrastructure Profile.
This attribute is named `remoteLogMode` in VSD API.
"""
self._remote_log_mode = value
@property
def remote_log_password(self):
""" Get remote_log_password value.
Notes:
Password to be used when accessing the remote log server via SCP or SFTP. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogPassword` in VSD API.
"""
return self._remote_log_password
@remote_log_password.setter
def remote_log_password(self, value):
""" Set remote_log_password value.
Notes:
Password to be used when accessing the remote log server via SCP or SFTP. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogPassword` in VSD API.
"""
self._remote_log_password = value
@property
def remote_log_server_address(self):
""" Get remote_log_server_address value.
Notes:
Primary Log Server for system logs generated by Gateways associated with this Infrastructure Profile. Can be an IP address or a URL. This field is optional.
This attribute is named `remoteLogServerAddress` in VSD API.
"""
return self._remote_log_server_address
@remote_log_server_address.setter
def remote_log_server_address(self, value):
""" Set remote_log_server_address value.
Notes:
Primary Log Server for system logs generated by Gateways associated with this Infrastructure Profile. Can be an IP address or a URL. This field is optional.
This attribute is named `remoteLogServerAddress` in VSD API.
"""
self._remote_log_server_address = value
@property
def remote_log_server_port(self):
""" Get remote_log_server_port value.
Notes:
Port to be used to access the Remote Syslog server. By default, this is port 514.
This attribute is named `remoteLogServerPort` in VSD API.
"""
return self._remote_log_server_port
@remote_log_server_port.setter
def remote_log_server_port(self, value):
""" Set remote_log_server_port value.
Notes:
Port to be used to access the Remote Syslog server. By default, this is port 514.
This attribute is named `remoteLogServerPort` in VSD API.
"""
self._remote_log_server_port = value
@property
def remote_log_username(self):
""" Get remote_log_username value.
Notes:
Username to be used when accessing the remote log server via SCP or SFTP. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogUsername` in VSD API.
"""
return self._remote_log_username
@remote_log_username.setter
def remote_log_username(self, value):
""" Set remote_log_username value.
Notes:
Username to be used when accessing the remote log server via SCP or SFTP. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogUsername` in VSD API.
"""
self._remote_log_username = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Profile instance created.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Profile instance created.
"""
self._description = value
@property
def metadata_upgrade_path(self):
""" Get metadata_upgrade_path value.
Notes:
Path/URL to retrieve the NSG Upgrade information meta data files. From that meta data, the NSG will be able to retrieve the upgrade package files and perform some validations. It is expected that the meta data file is in JSON format. RFC 2616 states that there are no 'official' maximum length for a URL but different browsers and servers have limits. Our friendly Internet Explorer has a maximum of 'around' 2048 characters, we shall use this as a limit here.
This attribute is named `metadataUpgradePath` in VSD API.
"""
return self._metadata_upgrade_path
@metadata_upgrade_path.setter
def metadata_upgrade_path(self, value):
""" Set metadata_upgrade_path value.
Notes:
Path/URL to retrieve the NSG Upgrade information meta data files. From that meta data, the NSG will be able to retrieve the upgrade package files and perform some validations. It is expected that the meta data file is in JSON format. RFC 2616 states that there are no 'official' maximum length for a URL but different browsers and servers have limits. Our friendly Internet Explorer has a maximum of 'around' 2048 characters, we shall use this as a limit here.
This attribute is named `metadataUpgradePath` in VSD API.
"""
self._metadata_upgrade_path = value
@property
def flow_eviction_threshold(self):
""" Get flow_eviction_threshold value.
Notes:
Number of flows at which eviction from kernel flow table will be triggered (default: 2500)
This attribute is named `flowEvictionThreshold` in VSD API.
"""
return self._flow_eviction_threshold
@flow_eviction_threshold.setter
def flow_eviction_threshold(self, value):
""" Set flow_eviction_threshold value.
Notes:
Number of flows at which eviction from kernel flow table will be triggered (default: 2500)
This attribute is named `flowEvictionThreshold` in VSD API.
"""
self._flow_eviction_threshold = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def upgrade_action(self):
""" Get upgrade_action value.
Notes:
Upgrade action for NSG associated with this Infrastructure Gateway Profile instance.
This attribute is named `upgradeAction` in VSD API.
"""
return self._upgrade_action
@upgrade_action.setter
def upgrade_action(self, value):
""" Set upgrade_action value.
Notes:
Upgrade action for NSG associated with this Infrastructure Gateway Profile instance.
This attribute is named `upgradeAction` in VSD API.
"""
self._upgrade_action = value
@property
def proxy_dns_name(self):
""" Get proxy_dns_name value.
Notes:
Proxy DNS Name : DNS Name of the system acting as a proxy between the NSG instances and the VSD.
This attribute is named `proxyDNSName` in VSD API.
"""
return self._proxy_dns_name
@proxy_dns_name.setter
def proxy_dns_name(self, value):
""" Set proxy_dns_name value.
Notes:
Proxy DNS Name : DNS Name of the system acting as a proxy between the NSG instances and the VSD.
This attribute is named `proxyDNSName` in VSD API.
"""
self._proxy_dns_name = value
@property
def use_two_factor(self):
""" Get use_two_factor value.
Notes:
Use Two Factor : When set to true, the use of two independent authentication factors will be used to secure the installed NSG. When set to false, there is an assumption that the NSG is being installed in a secure environment and the installer is also trusted. The defaut value is true, using 2-factor.
This attribute is named `useTwoFactor` in VSD API.
"""
return self._use_two_factor
@use_two_factor.setter
def use_two_factor(self, value):
""" Set use_two_factor value.
Notes:
Use Two Factor : When set to true, the use of two independent authentication factors will be used to secure the installed NSG. When set to false, there is an assumption that the NSG is being installed in a secure environment and the installer is also trusted. The defaut value is true, using 2-factor.
This attribute is named `useTwoFactor` in VSD API.
"""
self._use_two_factor = value
@property
def stats_collector_port(self):
""" Get stats_collector_port value.
Notes:
The port to open by the proxy for stats collector to use
This attribute is named `statsCollectorPort` in VSD API.
"""
return self._stats_collector_port
@stats_collector_port.setter
def stats_collector_port(self, value):
""" Set stats_collector_port value.
Notes:
The port to open by the proxy for stats collector to use
This attribute is named `statsCollectorPort` in VSD API.
"""
self._stats_collector_port = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def system_sync_scheduler(self):
""" Get system_sync_scheduler value.
Notes:
Time in a Cron format when configuration update are being applied on the Gateway (NSG). This property is linked to systemSyncWindow. Default value is every midnight (0 0 * * *). Format: Minutes Hours DayOfMonth Month DayOfWeek
This attribute is named `systemSyncScheduler` in VSD API.
"""
return self._system_sync_scheduler
@system_sync_scheduler.setter
def system_sync_scheduler(self, value):
""" Set system_sync_scheduler value.
Notes:
Time in a Cron format when configuration update are being applied on the Gateway (NSG). This property is linked to systemSyncWindow. Default value is every midnight (0 0 * * *). Format: Minutes Hours DayOfMonth Month DayOfWeek
This attribute is named `systemSyncScheduler` in VSD API.
"""
self._system_sync_scheduler = value
@property
def system_sync_window(self):
""" Get system_sync_window value.
Notes:
Length of time, in seconds, given to a Gateway to apply a configuration change. This property is closely linked to systemSyncScheduler.
This attribute is named `systemSyncWindow` in VSD API.
"""
return self._system_sync_window
@system_sync_window.setter
def system_sync_window(self, value):
""" Set system_sync_window value.
Notes:
Length of time, in seconds, given to a Gateway to apply a configuration change. This property is closely linked to systemSyncScheduler.
This attribute is named `systemSyncWindow` in VSD API.
"""
self._system_sync_window = value
Ancestors (in MRO)
- NUInfrastructureGatewayProfile
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_DEAD_TIMER_FIVE_HOURS
var CONST_DEAD_TIMER_FOUR_HOURS
var CONST_DEAD_TIMER_NONE
var CONST_DEAD_TIMER_ONE_HOUR
var CONST_DEAD_TIMER_SIX_HOURS
var CONST_DEAD_TIMER_TEN_MINUTES
var CONST_DEAD_TIMER_THIRTY_MINUTES
var CONST_DEAD_TIMER_THREE_HOURS
var CONST_DEAD_TIMER_TWO_HOURS
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_REMOTE_LOG_MODE_DISABLED
var CONST_REMOTE_LOG_MODE_RSYSLOG
var CONST_REMOTE_LOG_MODE_SCP
var CONST_REMOTE_LOG_MODE_SFTP
var CONST_SYSTEM_SYNC_WINDOW_FIVE_HOURS
var CONST_SYSTEM_SYNC_WINDOW_FOUR_HOURS
var CONST_SYSTEM_SYNC_WINDOW_NONE
var CONST_SYSTEM_SYNC_WINDOW_ONE_HOUR
var CONST_SYSTEM_SYNC_WINDOW_SIX_HOURS
var CONST_SYSTEM_SYNC_WINDOW_TEN_MINUTES
var CONST_SYSTEM_SYNC_WINDOW_THIRTY_MINUTES
var CONST_SYSTEM_SYNC_WINDOW_THREE_HOURS
var CONST_SYSTEM_SYNC_WINDOW_TWO_HOURS
var CONST_UPGRADE_ACTION_DOWNLOAD_AND_UPGRADE_AT_WINDOW
var CONST_UPGRADE_ACTION_DOWNLOAD_AND_UPGRADE_NOW
var CONST_UPGRADE_ACTION_DOWNLOAD_ONLY
var CONST_UPGRADE_ACTION_NONE
var CONST_UPGRADE_ACTION_UPGRADE_AT_BOOTSTRAPPING
var CONST_UPGRADE_ACTION_UPGRADE_NOW
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var datapath_sync_timeout
Get datapath_sync_timeout value.
Notes: Datapath flows sync-time-interval specified in milliseconds (default: 1000)
This attribute is named `datapathSyncTimeout` in VSD API.
var dead_timer
Get dead_timer value.
Notes: Time, in seconds, allowed for a Gateway to be inactive before the VSD revokes its certificates and marks it as untrusted.
This attribute is named `deadTimer` in VSD API.
var description
Get description value.
Notes: A description of the Profile instance created.
var enterprise_id
Get enterprise_id value.
Notes: Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_eviction_threshold
Get flow_eviction_threshold value.
Notes: Number of flows at which eviction from kernel flow table will be triggered (default: 2500)
This attribute is named `flowEvictionThreshold` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_upgrade_path
Get metadata_upgrade_path value.
Notes: Path/URL to retrieve the NSG Upgrade information meta data files. From that meta data, the NSG will be able to retrieve the upgrade package files and perform some validations. It is expected that the meta data file is in JSON format. RFC 2616 states that there are no 'official' maximum length for a URL but different browsers and servers have limits. Our friendly Internet Explorer has a maximum of 'around' 2048 characters, we shall use this as a limit here.
This attribute is named `metadataUpgradePath` in VSD API.
var metadatas
var name
Get name value.
Notes: Name of the Infrastructure Profile
var ntp_server_key
Get ntp_server_key value.
Notes: If set, this represents the security key for the Gateway to communicate with the NTP server (a VSC).
This attribute is named `NTPServerKey` in VSD API.
var ntp_server_key_id
Get ntp_server_key_id value.
Notes: Correspond to the key ID on the NTP server that matches the ntpServerKey value. Valid values are from 1 to 255 as specified by SR-OS and 0 to specify unused (VSD/NSG only).
This attribute is named `NTPServerKeyID` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var proxy_dns_name
Get proxy_dns_name value.
Notes: Proxy DNS Name : DNS Name of the system acting as a proxy between the NSG instances and the VSD.
This attribute is named `proxyDNSName` in VSD API.
var remote_log_dir_path
Get remote_log_dir_path value.
Notes: Path on the remote log server where the logs generated by the NSG are to be stored. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogDirPath` in VSD API.
var remote_log_mode
Get remote_log_mode value.
Notes: Type of Log Server for system logs generated by Gateways associated with this Infrastructure Profile.
This attribute is named `remoteLogMode` in VSD API.
var remote_log_password
Get remote_log_password value.
Notes: Password to be used when accessing the remote log server via SCP or SFTP. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogPassword` in VSD API.
var remote_log_server_address
Get remote_log_server_address value.
Notes: Primary Log Server for system logs generated by Gateways associated with this Infrastructure Profile. Can be an IP address or a URL. This field is optional.
This attribute is named `remoteLogServerAddress` in VSD API.
var remote_log_server_port
Get remote_log_server_port value.
Notes: Port to be used to access the Remote Syslog server. By default, this is port 514.
This attribute is named `remoteLogServerPort` in VSD API.
var remote_log_username
Get remote_log_username value.
Notes: Username to be used when accessing the remote log server via SCP or SFTP. This field is only useful for SCP and SFTP.
This attribute is named `remoteLogUsername` in VSD API.
var stats_collector_port
Get stats_collector_port value.
Notes: The port to open by the proxy for stats collector to use
This attribute is named `statsCollectorPort` in VSD API.
var system_sync_scheduler
Get system_sync_scheduler value.
Notes: Time in a Cron format when configuration update are being applied on the Gateway (NSG). This property is linked to systemSyncWindow. Default value is every midnight (0 0 * ). Format: Minutes Hours DayOfMonth Month DayOfWeek
This attribute is named `systemSyncScheduler` in VSD API.
var system_sync_window
Get system_sync_window value.
Notes: Length of time, in seconds, given to a Gateway to apply a configuration change. This property is closely linked to systemSyncScheduler.
This attribute is named `systemSyncWindow` in VSD API.
var upgrade_action
Get upgrade_action value.
Notes: Upgrade action for NSG associated with this Infrastructure Gateway Profile instance.
This attribute is named `upgradeAction` in VSD API.
var use_two_factor
Get use_two_factor value.
Notes: Use Two Factor : When set to true, the use of two independent authentication factors will be used to secure the installed NSG. When set to false, there is an assumption that the NSG is being installed in a secure environment and the installer is also trusted. The defaut value is true, using 2-factor.
This attribute is named `useTwoFactor` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a InfrastructureGatewayProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> infrastructuregatewayprofile = NUInfrastructureGatewayProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureGatewayProfile') >>> infrastructuregatewayprofile = NUInfrastructureGatewayProfile(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a InfrastructureGatewayProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructuregatewayprofile = NUInfrastructureGatewayProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureGatewayProfile')
>>> infrastructuregatewayprofile = NUInfrastructureGatewayProfile(data=my_dict)
"""
super(NUInfrastructureGatewayProfile, self).__init__()
# Read/Write Attributes
self._ntp_server_key = None
self._ntp_server_key_id = None
self._name = None
self._last_updated_by = None
self._datapath_sync_timeout = None
self._dead_timer = None
self._remote_log_dir_path = None
self._remote_log_mode = None
self._remote_log_password = None
self._remote_log_server_address = None
self._remote_log_server_port = None
self._remote_log_username = None
self._description = None
self._metadata_upgrade_path = None
self._flow_eviction_threshold = None
self._enterprise_id = None
self._entity_scope = None
self._upgrade_action = None
self._proxy_dns_name = None
self._use_two_factor = None
self._stats_collector_port = None
self._external_id = None
self._system_sync_scheduler = None
self._system_sync_window = None
self.expose_attribute(local_name="ntp_server_key", remote_name="NTPServerKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server_key_id", remote_name="NTPServerKeyID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="dead_timer", remote_name="deadTimer", attribute_type=str, is_required=False, is_unique=False, choices=[u'FIVE_HOURS', u'FOUR_HOURS', u'NONE', u'ONE_HOUR', u'SIX_HOURS', u'TEN_MINUTES', u'THIRTY_MINUTES', u'THREE_HOURS', u'TWO_HOURS'])
self.expose_attribute(local_name="remote_log_dir_path", remote_name="remoteLogDirPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_mode", remote_name="remoteLogMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'RSYSLOG', u'SCP', u'SFTP'])
self.expose_attribute(local_name="remote_log_password", remote_name="remoteLogPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_server_address", remote_name="remoteLogServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_server_port", remote_name="remoteLogServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="remote_log_username", remote_name="remoteLogUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_upgrade_path", remote_name="metadataUpgradePath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="upgrade_action", remote_name="upgradeAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOWNLOAD_AND_UPGRADE_AT_WINDOW', u'DOWNLOAD_AND_UPGRADE_NOW', u'DOWNLOAD_ONLY', u'NONE', u'UPGRADE_AT_BOOTSTRAPPING', u'UPGRADE_NOW'])
self.expose_attribute(local_name="proxy_dns_name", remote_name="proxyDNSName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="use_two_factor", remote_name="useTwoFactor", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_port", remote_name="statsCollectorPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_sync_scheduler", remote_name="systemSyncScheduler", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="system_sync_window", remote_name="systemSyncWindow", attribute_type=str, is_required=False, is_unique=False, choices=[u'FIVE_HOURS', u'FOUR_HOURS', u'NONE', u'ONE_HOUR', u'SIX_HOURS', u'TEN_MINUTES', u'THIRTY_MINUTES', u'THREE_HOURS', u'TWO_HOURS'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUInfrastructurePortProfile
Represents a InfrastructurePortProfile in the VSD
Notes: Represents an Infrastructure Port Profile.
class NUInfrastructurePortProfile(NURESTObject):
""" Represents a InfrastructurePortProfile in the VSD
Notes:
Represents an Infrastructure Port Profile.
"""
__rest_name__ = "infrastructureportprofile"
__resource_name__ = "infrastructureportprofiles"
## Constants
CONST_DUPLEX_HALF = "HALF"
CONST_SPEED_BASETX100 = "BASETX100"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_DUPLEX_FULL = "FULL"
CONST_DUPLEX_SIMPLEX = "SIMPLEX"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_UPLINK_TAG_PRIMARY = "PRIMARY"
CONST_UPLINK_TAG_UNKNOWN = "UNKNOWN"
CONST_SPEED_BASET1000 = "BASET1000"
CONST_SPEED_BASEX10G = "BASEX10G"
CONST_UPLINK_TAG_TERTIARY = "TERTIARY"
CONST_UPLINK_TAG_SECONDARY = "SECONDARY"
CONST_SPEED_AUTONEGOTIATE = "AUTONEGOTIATE"
CONST_SPEED_BASET10 = "BASET10"
def __init__(self, **kwargs):
""" Initializes a InfrastructurePortProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructureportprofile = NUInfrastructurePortProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructurePortProfile')
>>> infrastructureportprofile = NUInfrastructurePortProfile(data=my_dict)
"""
super(NUInfrastructurePortProfile, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._speed = None
self._uplink_tag = None
self._mtu = None
self._duplex = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="speed", remote_name="speed", attribute_type=str, is_required=False, is_unique=False, choices=[u'AUTONEGOTIATE', u'BASET10', u'BASET1000', u'BASETX100', u'BASEX10G'])
self.expose_attribute(local_name="uplink_tag", remote_name="uplinkTag", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'SECONDARY', u'TERTIARY', u'UNKNOWN'])
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="duplex", remote_name="duplex", attribute_type=str, is_required=False, is_unique=False, choices=[u'FULL', u'HALF', u'SIMPLEX'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Infrastructure Profile
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Infrastructure Profile
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Profile instance created.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Profile instance created.
"""
self._description = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def speed(self):
""" Get speed value.
Notes:
Port Speed in Mb/s : Supported Ethernet speeds are 10 (10Base-T), 100 (Fast-ethernet 100Base-TX), 1000 (Gigabit Ethernet 1000Base-T), 10 000 (10 Gigabit Ethernet 10GBase-X), and Auto-Negotiate.
"""
return self._speed
@speed.setter
def speed(self, value):
""" Set speed value.
Notes:
Port Speed in Mb/s : Supported Ethernet speeds are 10 (10Base-T), 100 (Fast-ethernet 100Base-TX), 1000 (Gigabit Ethernet 1000Base-T), 10 000 (10 Gigabit Ethernet 10GBase-X), and Auto-Negotiate.
"""
self._speed = value
@property
def uplink_tag(self):
""" Get uplink_tag value.
Notes:
To allow prioritisation of traffic, the NSG network ports must be configured with an uplink type or tag value which will be used in the identification of packets being forwarded. That identification is at the base of the selection of which network port will serve in sending packets to the outside world. The default value is PRIMARY. Possible values are PRIMARY, SECONDARY, TERTIARY, UNKNOWN, .
This attribute is named `uplinkTag` in VSD API.
"""
return self._uplink_tag
@uplink_tag.setter
def uplink_tag(self, value):
""" Set uplink_tag value.
Notes:
To allow prioritisation of traffic, the NSG network ports must be configured with an uplink type or tag value which will be used in the identification of packets being forwarded. That identification is at the base of the selection of which network port will serve in sending packets to the outside world. The default value is PRIMARY. Possible values are PRIMARY, SECONDARY, TERTIARY, UNKNOWN, .
This attribute is named `uplinkTag` in VSD API.
"""
self._uplink_tag = value
@property
def mtu(self):
""" Get mtu value.
Notes:
Port MTU (Maximum Transmission Unit) : The size in octets of the largest protocol data unit (PDU) that the layer can pass on. The default value is normally 1500 octets for Ethernet v2 and can go up to 9198 for Jumbo Frames.
"""
return self._mtu
@mtu.setter
def mtu(self, value):
""" Set mtu value.
Notes:
Port MTU (Maximum Transmission Unit) : The size in octets of the largest protocol data unit (PDU) that the layer can pass on. The default value is normally 1500 octets for Ethernet v2 and can go up to 9198 for Jumbo Frames.
"""
self._mtu = value
@property
def duplex(self):
""" Get duplex value.
Notes:
Port Duplex : Supported values are FULL where both parties can communicate to the other simultaneously and HALF where each party can only communicate to each other in one direction at a time.
"""
return self._duplex
@duplex.setter
def duplex(self, value):
""" Set duplex value.
Notes:
Port Duplex : Supported values are FULL where both parties can communicate to the other simultaneously and HALF where each party can only communicate to each other in one direction at a time.
"""
self._duplex = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUInfrastructurePortProfile
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_DUPLEX_FULL
var CONST_DUPLEX_HALF
var CONST_DUPLEX_SIMPLEX
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SPEED_AUTONEGOTIATE
var CONST_SPEED_BASET10
var CONST_SPEED_BASET1000
var CONST_SPEED_BASETX100
var CONST_SPEED_BASEX10G
var CONST_UPLINK_TAG_PRIMARY
var CONST_UPLINK_TAG_SECONDARY
var CONST_UPLINK_TAG_TERTIARY
var CONST_UPLINK_TAG_UNKNOWN
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Profile instance created.
var duplex
Get duplex value.
Notes: Port Duplex : Supported values are FULL where both parties can communicate to the other simultaneously and HALF where each party can only communicate to each other in one direction at a time.
var enterprise_id
Get enterprise_id value.
Notes: Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var mtu
Get mtu value.
Notes: Port MTU (Maximum Transmission Unit) : The size in octets of the largest protocol data unit (PDU) that the layer can pass on. The default value is normally 1500 octets for Ethernet v2 and can go up to 9198 for Jumbo Frames.
var name
Get name value.
Notes: Name of the Infrastructure Profile
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var speed
Get speed value.
Notes: Port Speed in Mb/s : Supported Ethernet speeds are 10 (10Base-T), 100 (Fast-ethernet 100Base-TX), 1000 (Gigabit Ethernet 1000Base-T), 10 000 (10 Gigabit Ethernet 10GBase-X), and Auto-Negotiate.
var uplink_tag
Get uplink_tag value.
Notes: To allow prioritisation of traffic, the NSG network ports must be configured with an uplink type or tag value which will be used in the identification of packets being forwarded. That identification is at the base of the selection of which network port will serve in sending packets to the outside world. The default value is PRIMARY. Possible values are PRIMARY, SECONDARY, TERTIARY, UNKNOWN, .
This attribute is named `uplinkTag` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a InfrastructurePortProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> infrastructureportprofile = NUInfrastructurePortProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructurePortProfile') >>> infrastructureportprofile = NUInfrastructurePortProfile(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a InfrastructurePortProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructureportprofile = NUInfrastructurePortProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructurePortProfile')
>>> infrastructureportprofile = NUInfrastructurePortProfile(data=my_dict)
"""
super(NUInfrastructurePortProfile, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._speed = None
self._uplink_tag = None
self._mtu = None
self._duplex = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="speed", remote_name="speed", attribute_type=str, is_required=False, is_unique=False, choices=[u'AUTONEGOTIATE', u'BASET10', u'BASET1000', u'BASETX100', u'BASEX10G'])
self.expose_attribute(local_name="uplink_tag", remote_name="uplinkTag", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'SECONDARY', u'TERTIARY', u'UNKNOWN'])
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="duplex", remote_name="duplex", attribute_type=str, is_required=False, is_unique=False, choices=[u'FULL', u'HALF', u'SIMPLEX'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUInfrastructureVscProfile
Represents a InfrastructureVscProfile in the VSD
Notes: Represents an Infrastructure VSC Profile.
class NUInfrastructureVscProfile(NURESTObject):
""" Represents a InfrastructureVscProfile in the VSD
Notes:
Represents an Infrastructure VSC Profile.
"""
__rest_name__ = "infrastructurevscprofile"
__resource_name__ = "infrastructurevscprofiles"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a InfrastructureVscProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructurevscprofile = NUInfrastructureVscProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureVscProfile')
>>> infrastructurevscprofile = NUInfrastructureVscProfile(data=my_dict)
"""
super(NUInfrastructureVscProfile, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._second_controller = None
self._description = None
self._first_controller = None
self._enterprise_id = None
self._entity_scope = None
self._probe_interval = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="second_controller", remote_name="secondController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="first_controller", remote_name="firstController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="probe_interval", remote_name="probeInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Infrastructure Profile
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Infrastructure Profile
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def second_controller(self):
""" Get second_controller value.
Notes:
Second VSC Controller : IP Address of the secondary VSC system NSG instances associated to this profile will be reaching for.
This attribute is named `secondController` in VSD API.
"""
return self._second_controller
@second_controller.setter
def second_controller(self, value):
""" Set second_controller value.
Notes:
Second VSC Controller : IP Address of the secondary VSC system NSG instances associated to this profile will be reaching for.
This attribute is named `secondController` in VSD API.
"""
self._second_controller = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Profile instance created.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Profile instance created.
"""
self._description = value
@property
def first_controller(self):
""" Get first_controller value.
Notes:
First VSC Controller : IP Address of the first VSC system NSG instances associated to this profile will be reaching for.
This attribute is named `firstController` in VSD API.
"""
return self._first_controller
@first_controller.setter
def first_controller(self, value):
""" Set first_controller value.
Notes:
First VSC Controller : IP Address of the first VSC system NSG instances associated to this profile will be reaching for.
This attribute is named `firstController` in VSD API.
"""
self._first_controller = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def probe_interval(self):
""" Get probe_interval value.
Notes:
Openflow echo timer in millisecond
This attribute is named `probeInterval` in VSD API.
"""
return self._probe_interval
@probe_interval.setter
def probe_interval(self, value):
""" Set probe_interval value.
Notes:
Openflow echo timer in millisecond
This attribute is named `probeInterval` in VSD API.
"""
self._probe_interval = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUInfrastructureVscProfile
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Profile instance created.
var enterprise_id
Get enterprise_id value.
Notes: Enterprise/Organisation associated with this Profile instance.
This attribute is named `enterpriseID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var first_controller
Get first_controller value.
Notes: First VSC Controller : IP Address of the first VSC system NSG instances associated to this profile will be reaching for.
This attribute is named `firstController` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Infrastructure Profile
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var probe_interval
Get probe_interval value.
Notes: Openflow echo timer in millisecond
This attribute is named `probeInterval` in VSD API.
var second_controller
Get second_controller value.
Notes: Second VSC Controller : IP Address of the secondary VSC system NSG instances associated to this profile will be reaching for.
This attribute is named `secondController` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a InfrastructureVscProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> infrastructurevscprofile = NUInfrastructureVscProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureVscProfile') >>> infrastructurevscprofile = NUInfrastructureVscProfile(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a InfrastructureVscProfile instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> infrastructurevscprofile = NUInfrastructureVscProfile(id=u'xxxx-xxx-xxx-xxx', name=u'InfrastructureVscProfile')
>>> infrastructurevscprofile = NUInfrastructureVscProfile(data=my_dict)
"""
super(NUInfrastructureVscProfile, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._second_controller = None
self._description = None
self._first_controller = None
self._enterprise_id = None
self._entity_scope = None
self._probe_interval = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="second_controller", remote_name="secondController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="first_controller", remote_name="firstController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="probe_interval", remote_name="probeInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUIngressACLEntryTemplate
Represents a IngressACLEntryTemplate in the VSD
Notes: Defines the template of Ingress ACL entries
class NUIngressACLEntryTemplate(NURESTObject):
""" Represents a IngressACLEntryTemplate in the VSD
Notes:
Defines the template of Ingress ACL entries
"""
__rest_name__ = "ingressaclentrytemplate"
__resource_name__ = "ingressaclentrytemplates"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ACTION_REDIRECT = "REDIRECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_NETWORK_TYPE_ENDPOINT_ZONE = "ENDPOINT_ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_LOCATION_TYPE_ANY = "ANY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_NETWORK_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_NETWORK_TYPE_ENDPOINT_DOMAIN = "ENDPOINT_DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_NETWORK_TYPE_ANY = "ANY"
CONST_LOCATION_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_LOCATION_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_LOCATION_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_LOCATION_TYPE_REDIRECTIONTARGET = "REDIRECTIONTARGET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ACTION_DROP = "DROP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_NETWORK_TYPE_INTERNET_POLICYGROUP = "INTERNET_POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_LOCATION_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_NETWORK_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ACTION_FORWARD = "FORWARD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_NETWORK_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_NETWORK_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_NETWORK_TYPE_ENDPOINT_SUBNET = "ENDPOINT_SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
def __init__(self, **kwargs):
""" Initializes a IngressACLEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressaclentrytemplate = NUIngressACLEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressACLEntryTemplate')
>>> ingressaclentrytemplate = NUIngressACLEntryTemplate(data=my_dict)
"""
super(NUIngressACLEntryTemplate, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._reflexive = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def action(self):
""" Get action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry Possible values are DROP, FORWARD, REDIRECT, .
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry Possible values are DROP, FORWARD, REDIRECT, .
"""
self._action = value
@property
def address_override(self):
""" Get address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
return self._address_override
@address_override.setter
def address_override(self, value):
""" Set address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
self._address_override = value
@property
def reflexive(self):
""" Get reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
return self._reflexive
@reflexive.setter
def reflexive(self, value):
""" Set reflexive value.
Notes:
True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
"""
self._reflexive = value
@property
def description(self):
""" Get description value.
Notes:
Description of the ACL entry
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the ACL entry
"""
self._description = value
@property
def destination_port(self):
""" Get destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
return self._destination_port
@destination_port.setter
def destination_port(self, value):
""" Set destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
self._destination_port = value
@property
def network_id(self):
""" Get network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
return self._network_id
@network_id.setter
def network_id(self, value):
""" Set network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
self._network_id = value
@property
def network_type(self):
""" Get network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
return self._network_type
@network_type.setter
def network_type(self, value):
""" Set network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
self._network_type = value
@property
def flow_logging_enabled(self):
""" Get flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
return self._flow_logging_enabled
@flow_logging_enabled.setter
def flow_logging_enabled(self, value):
""" Set flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
self._flow_logging_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location_id(self):
""" Get location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
return self._location_id
@location_id.setter
def location_id(self, value):
""" Set location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
self._location_id = value
@property
def location_type(self):
""" Get location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
return self._location_type
@location_type.setter
def location_type(self, value):
""" Set location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
self._location_type = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def source_port(self):
""" Get source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
return self._source_port
@source_port.setter
def source_port(self, value):
""" Set source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
self._source_port = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def protocol(self):
""" Get protocol value.
Notes:
Protocol number that must be matched
"""
return self._protocol
@protocol.setter
def protocol(self, value):
""" Set protocol value.
Notes:
Protocol number that must be matched
"""
self._protocol = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def stats_id(self):
""" Get stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
return self._stats_id
@stats_id.setter
def stats_id(self, value):
""" Set stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
self._stats_id = value
@property
def stats_logging_enabled(self):
""" Get stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
return self._stats_logging_enabled
@stats_logging_enabled.setter
def stats_logging_enabled(self, value):
""" Set stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
self._stats_logging_enabled = value
@property
def ether_type(self):
""" Get ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
return self._ether_type
@ether_type.setter
def ether_type(self, value):
""" Set ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
self._ether_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
Ancestors (in MRO)
- NUIngressACLEntryTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_DROP
var CONST_ACTION_FORWARD
var CONST_ACTION_REDIRECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_LOCATION_TYPE_ANY
var CONST_LOCATION_TYPE_POLICYGROUP
var CONST_LOCATION_TYPE_REDIRECTIONTARGET
var CONST_LOCATION_TYPE_SUBNET
var CONST_LOCATION_TYPE_VPORTTAG
var CONST_LOCATION_TYPE_ZONE
var CONST_NETWORK_TYPE_ANY
var CONST_NETWORK_TYPE_ENDPOINT_DOMAIN
var CONST_NETWORK_TYPE_ENDPOINT_SUBNET
var CONST_NETWORK_TYPE_ENDPOINT_ZONE
var CONST_NETWORK_TYPE_ENTERPRISE_NETWORK
var CONST_NETWORK_TYPE_INTERNET_POLICYGROUP
var CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP
var CONST_NETWORK_TYPE_POLICYGROUP
var CONST_NETWORK_TYPE_PUBLIC_NETWORK
var CONST_NETWORK_TYPE_SUBNET
var CONST_NETWORK_TYPE_ZONE
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry Possible values are DROP, FORWARD, REDIRECT, .
var address_override
Get address_override value.
Notes: Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the ACL entry
var destination_port
Get destination_port value.
Notes: The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
var dscp
Get dscp value.
Notes: DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var ether_type
Get ether_type value.
Notes: Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_logging_enabled
Get flow_logging_enabled value.
Notes: Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location_id
Get location_id value.
Notes: The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
var location_type
Get location_type value.
Notes: Type of the location entity.
This attribute is named `locationType` in VSD API.
var metadatas
var network_id
Get network_id value.
Notes: The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
var network_type
Get network_type value.
Notes: Type of the source network.
This attribute is named `networkType` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy.
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var protocol
Get protocol value.
Notes: Protocol number that must be matched
var reflexive
Get reflexive value.
Notes: True means that this ACL entry is reflexive, so there will be a corresponding rule that will be created by OVS in the network. False means that there is no corresponding rule created by OVS in the network.
var source_port
Get source_port value.
Notes: Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
var statistics
var stats_id
Get stats_id value.
Notes: The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
var stats_logging_enabled
Get stats_logging_enabled value.
Notes: Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a IngressACLEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ingressaclentrytemplate = NUIngressACLEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressACLEntryTemplate') >>> ingressaclentrytemplate = NUIngressACLEntryTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a IngressACLEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressaclentrytemplate = NUIngressACLEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressACLEntryTemplate')
>>> ingressaclentrytemplate = NUIngressACLEntryTemplate(data=my_dict)
"""
super(NUIngressACLEntryTemplate, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._reflexive = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive", remote_name="reflexive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUIngressACLTemplate
Represents a IngressACLTemplate in the VSD
Notes: Defines the template for an Ingress ACL.
class NUIngressACLTemplate(NURESTObject):
""" Represents a IngressACLTemplate in the VSD
Notes:
Defines the template for an Ingress ACL.
"""
__rest_name__ = "ingressacltemplate"
__resource_name__ = "ingressacltemplates"
## Constants
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PRIORITY_TYPE_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PRIORITY_TYPE_TOP = "TOP"
CONST_PRIORITY_TYPE_BOTTOM = "BOTTOM"
def __init__(self, **kwargs):
""" Initializes a IngressACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressacltemplate = NUIngressACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressACLTemplate')
>>> ingressacltemplate = NUIngressACLTemplate(data=my_dict)
"""
super(NUIngressACLTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._description = None
self._allow_l2_address_spoof = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._assoc_acl_template_id = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_l2_address_spoof", remote_name="allowL2AddressSpoof", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="assoc_acl_template_id", remote_name="assocAclTemplateId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The name of the entity
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the entity
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def active(self):
""" Get active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
self._active = value
@property
def default_allow_ip(self):
""" Get default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
return self._default_allow_ip
@default_allow_ip.setter
def default_allow_ip(self, value):
""" Set default_allow_ip value.
Notes:
If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
"""
self._default_allow_ip = value
@property
def default_allow_non_ip(self):
""" Get default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
return self._default_allow_non_ip
@default_allow_non_ip.setter
def default_allow_non_ip(self, value):
""" Set default_allow_non_ip value.
Notes:
If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
"""
self._default_allow_non_ip = value
@property
def description(self):
""" Get description value.
Notes:
A description of the entity
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the entity
"""
self._description = value
@property
def allow_l2_address_spoof(self):
""" Get allow_l2_address_spoof value.
Notes:
If enabled, it will disable the default anti-spoof ACL for this domain that essentially prevents any VM to send packets that do not originate from that particular VM
This attribute is named `allowL2AddressSpoof` in VSD API.
"""
return self._allow_l2_address_spoof
@allow_l2_address_spoof.setter
def allow_l2_address_spoof(self, value):
""" Set allow_l2_address_spoof value.
Notes:
If enabled, it will disable the default anti-spoof ACL for this domain that essentially prevents any VM to send packets that do not originate from that particular VM
This attribute is named `allowL2AddressSpoof` in VSD API.
"""
self._allow_l2_address_spoof = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def priority_type(self):
""" Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
return self._priority_type
@priority_type.setter
def priority_type(self, value):
""" Set priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
self._priority_type = value
@property
def assoc_acl_template_id(self):
""" Get assoc_acl_template_id value.
Notes:
ID of the ACL template associated with this ACL template
This attribute is named `assocAclTemplateId` in VSD API.
"""
return self._assoc_acl_template_id
@assoc_acl_template_id.setter
def assoc_acl_template_id(self, value):
""" Set assoc_acl_template_id value.
Notes:
ID of the ACL template associated with this ACL template
This attribute is named `assocAclTemplateId` in VSD API.
"""
self._assoc_acl_template_id = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
Ancestors (in MRO)
- NUIngressACLTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_PRIORITY_TYPE_BOTTOM
var CONST_PRIORITY_TYPE_NONE
var CONST_PRIORITY_TYPE_TOP
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: If enabled, it means that this ACL or QOS entry is active
var allow_l2_address_spoof
Get allow_l2_address_spoof value.
Notes: If enabled, it will disable the default anti-spoof ACL for this domain that essentially prevents any VM to send packets that do not originate from that particular VM
This attribute is named `allowL2AddressSpoof` in VSD API.
var assoc_acl_template_id
Get assoc_acl_template_id value.
Notes: ID of the ACL template associated with this ACL template
This attribute is named `assocAclTemplateId` in VSD API.
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var default_allow_ip
Get default_allow_ip value.
Notes: If enabled a default ACL of Allow All is added as the last entry in the list of ACL entries
This attribute is named `defaultAllowIP` in VSD API.
var default_allow_non_ip
Get default_allow_non_ip value.
Notes: If enabled, non ip traffic will be dropped
This attribute is named `defaultAllowNonIP` in VSD API.
var description
Get description value.
Notes: A description of the entity
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ingress_acl_entry_templates
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: The name of the entity
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var priority_type
Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
var vms
Methods
def __init__(
self, **kwargs)
Initializes a IngressACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ingressacltemplate = NUIngressACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressACLTemplate') >>> ingressacltemplate = NUIngressACLTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a IngressACLTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressacltemplate = NUIngressACLTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressACLTemplate')
>>> ingressacltemplate = NUIngressACLTemplate(data=my_dict)
"""
super(NUIngressACLTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._default_allow_ip = None
self._default_allow_non_ip = None
self._description = None
self._allow_l2_address_spoof = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._assoc_acl_template_id = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_ip", remote_name="defaultAllowIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="default_allow_non_ip", remote_name="defaultAllowNonIP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_l2_address_spoof", remote_name="allowL2AddressSpoof", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="assoc_acl_template_id", remote_name="assocAclTemplateId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUIngressAdvFwdEntryTemplate
Represents a IngressAdvFwdEntryTemplate in the VSD
Notes: Defines the template of Ingress Advanced Forwarding entries
class NUIngressAdvFwdEntryTemplate(NURESTObject):
""" Represents a IngressAdvFwdEntryTemplate in the VSD
Notes:
Defines the template of Ingress Advanced Forwarding entries
"""
__rest_name__ = "ingressadvfwdentrytemplate"
__resource_name__ = "ingressadvfwdentrytemplates"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ACTION_REDIRECT = "REDIRECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_NETWORK_TYPE_ENDPOINT_ZONE = "ENDPOINT_ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_LOCATION_TYPE_ANY = "ANY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_NETWORK_TYPE_ANY = "ANY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_FC_OVERRIDE_H = "H"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_FC_OVERRIDE_F = "F"
CONST_FC_OVERRIDE_G = "G"
CONST_FC_OVERRIDE_D = "D"
CONST_FC_OVERRIDE_E = "E"
CONST_FC_OVERRIDE_B = "B"
CONST_FC_OVERRIDE_C = "C"
CONST_FC_OVERRIDE_A = "A"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_UPLINK_PREFERENCE_PRIMARY_SECONDARY = "PRIMARY_SECONDARY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_UPLINK_PREFERENCE_PRIMARY = "PRIMARY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_NETWORK_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_NETWORK_TYPE_ENDPOINT_DOMAIN = "ENDPOINT_DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_FC_OVERRIDE_NONE = "NONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_UPLINK_PREFERENCE_SYMMETRIC = "SYMMETRIC"
CONST_LOCATION_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_LOCATION_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_LOCATION_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_LOCATION_TYPE_REDIRECTIONTARGET = "REDIRECTIONTARGET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ACTION_DROP = "DROP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_UPLINK_PREFERENCE_SECONDARY = "SECONDARY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_NETWORK_TYPE_INTERNET_POLICYGROUP = "INTERNET_POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_LOCATION_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_UPLINK_PREFERENCE_SECONDARY_PRIMARY = "SECONDARY_PRIMARY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_NETWORK_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ACTION_FORWARD = "FORWARD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_NETWORK_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_NETWORK_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_NETWORK_TYPE_ENDPOINT_SUBNET = "ENDPOINT_SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
def __init__(self, **kwargs):
""" Initializes a IngressAdvFwdEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressadvfwdentrytemplate = NUIngressAdvFwdEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressAdvFwdEntryTemplate')
>>> ingressadvfwdentrytemplate = NUIngressAdvFwdEntryTemplate(data=my_dict)
"""
super(NUIngressAdvFwdEntryTemplate, self).__init__()
# Read/Write Attributes
self._fc_override = None
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._redirect_vport_tag_id = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._uplink_preference = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="fc_override", remote_name="FCOverride", attribute_type=str, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redirect_vport_tag_id", remote_name="redirectVPortTagID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="uplink_preference", remote_name="uplinkPreference", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'PRIMARY_SECONDARY', u'SECONDARY', u'SECONDARY_PRIMARY', u'SYMMETRIC'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def fc_override(self):
""" Get fc_override value.
Notes:
Value of the Service Class to be overridden in the packet when the match conditions are satisfied Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `FCOverride` in VSD API.
"""
return self._fc_override
@fc_override.setter
def fc_override(self, value):
""" Set fc_override value.
Notes:
Value of the Service Class to be overridden in the packet when the match conditions are satisfied Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `FCOverride` in VSD API.
"""
self._fc_override = value
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def action(self):
""" Get action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry Possible values are DROP, FORWARD, REDIRECT, .
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry Possible values are DROP, FORWARD, REDIRECT, .
"""
self._action = value
@property
def address_override(self):
""" Get address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
return self._address_override
@address_override.setter
def address_override(self, value):
""" Set address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
self._address_override = value
@property
def redirect_vport_tag_id(self):
""" Get redirect_vport_tag_id value.
Notes:
VPort tag to which traffic will be redirected to, when ACL entry match criteria succeeds
This attribute is named `redirectVPortTagID` in VSD API.
"""
return self._redirect_vport_tag_id
@redirect_vport_tag_id.setter
def redirect_vport_tag_id(self, value):
""" Set redirect_vport_tag_id value.
Notes:
VPort tag to which traffic will be redirected to, when ACL entry match criteria succeeds
This attribute is named `redirectVPortTagID` in VSD API.
"""
self._redirect_vport_tag_id = value
@property
def description(self):
""" Get description value.
Notes:
Description of the ACL entry
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the ACL entry
"""
self._description = value
@property
def destination_port(self):
""" Get destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
return self._destination_port
@destination_port.setter
def destination_port(self, value):
""" Set destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
self._destination_port = value
@property
def network_id(self):
""" Get network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
return self._network_id
@network_id.setter
def network_id(self, value):
""" Set network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
self._network_id = value
@property
def network_type(self):
""" Get network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
return self._network_type
@network_type.setter
def network_type(self, value):
""" Set network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
self._network_type = value
@property
def flow_logging_enabled(self):
""" Get flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
return self._flow_logging_enabled
@flow_logging_enabled.setter
def flow_logging_enabled(self, value):
""" Set flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
self._flow_logging_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location_id(self):
""" Get location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
return self._location_id
@location_id.setter
def location_id(self, value):
""" Set location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
self._location_id = value
@property
def location_type(self):
""" Get location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
return self._location_type
@location_type.setter
def location_type(self, value):
""" Set location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
self._location_type = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy. Possible values are DRAFT, LIVE, .
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy. Possible values are DRAFT, LIVE, .
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def source_port(self):
""" Get source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
return self._source_port
@source_port.setter
def source_port(self, value):
""" Set source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
self._source_port = value
@property
def uplink_preference(self):
""" Get uplink_preference value.
Notes:
Indicates the preferencial path selection for network traffic for this ACL - Default is Primary 1 and Secondary 2 when the attribute is applicable.
This attribute is named `uplinkPreference` in VSD API.
"""
return self._uplink_preference
@uplink_preference.setter
def uplink_preference(self, value):
""" Set uplink_preference value.
Notes:
Indicates the preferencial path selection for network traffic for this ACL - Default is Primary 1 and Secondary 2 when the attribute is applicable.
This attribute is named `uplinkPreference` in VSD API.
"""
self._uplink_preference = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def protocol(self):
""" Get protocol value.
Notes:
Protocol number that must be matched
"""
return self._protocol
@protocol.setter
def protocol(self, value):
""" Set protocol value.
Notes:
Protocol number that must be matched
"""
self._protocol = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def stats_id(self):
""" Get stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
return self._stats_id
@stats_id.setter
def stats_id(self, value):
""" Set stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
self._stats_id = value
@property
def stats_logging_enabled(self):
""" Get stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
return self._stats_logging_enabled
@stats_logging_enabled.setter
def stats_logging_enabled(self, value):
""" Set stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
self._stats_logging_enabled = value
@property
def ether_type(self):
""" Get ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
return self._ether_type
@ether_type.setter
def ether_type(self, value):
""" Set ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
self._ether_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
Ancestors (in MRO)
- NUIngressAdvFwdEntryTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_DROP
var CONST_ACTION_FORWARD
var CONST_ACTION_REDIRECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_FC_OVERRIDE_A
var CONST_FC_OVERRIDE_B
var CONST_FC_OVERRIDE_C
var CONST_FC_OVERRIDE_D
var CONST_FC_OVERRIDE_E
var CONST_FC_OVERRIDE_F
var CONST_FC_OVERRIDE_G
var CONST_FC_OVERRIDE_H
var CONST_FC_OVERRIDE_NONE
var CONST_LOCATION_TYPE_ANY
var CONST_LOCATION_TYPE_POLICYGROUP
var CONST_LOCATION_TYPE_REDIRECTIONTARGET
var CONST_LOCATION_TYPE_SUBNET
var CONST_LOCATION_TYPE_VPORTTAG
var CONST_LOCATION_TYPE_ZONE
var CONST_NETWORK_TYPE_ANY
var CONST_NETWORK_TYPE_ENDPOINT_DOMAIN
var CONST_NETWORK_TYPE_ENDPOINT_SUBNET
var CONST_NETWORK_TYPE_ENDPOINT_ZONE
var CONST_NETWORK_TYPE_ENTERPRISE_NETWORK
var CONST_NETWORK_TYPE_INTERNET_POLICYGROUP
var CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP
var CONST_NETWORK_TYPE_POLICYGROUP
var CONST_NETWORK_TYPE_PUBLIC_NETWORK
var CONST_NETWORK_TYPE_SUBNET
var CONST_NETWORK_TYPE_ZONE
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_UPLINK_PREFERENCE_PRIMARY
var CONST_UPLINK_PREFERENCE_PRIMARY_SECONDARY
var CONST_UPLINK_PREFERENCE_SECONDARY
var CONST_UPLINK_PREFERENCE_SECONDARY_PRIMARY
var CONST_UPLINK_PREFERENCE_SYMMETRIC
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry Possible values are DROP, FORWARD, REDIRECT, .
var address_override
Get address_override value.
Notes: Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the ACL entry
var destination_port
Get destination_port value.
Notes: The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
var dscp
Get dscp value.
Notes: DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var ether_type
Get ether_type value.
Notes: Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fc_override
Get fc_override value.
Notes: Value of the Service Class to be overridden in the packet when the match conditions are satisfied Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `FCOverride` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_logging_enabled
Get flow_logging_enabled value.
Notes: Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location_id
Get location_id value.
Notes: The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
var location_type
Get location_type value.
Notes: Type of the location entity.
This attribute is named `locationType` in VSD API.
var metadatas
var network_id
Get network_id value.
Notes: The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
var network_type
Get network_type value.
Notes: Type of the source network.
This attribute is named `networkType` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy. Possible values are DRAFT, LIVE, .
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var protocol
Get protocol value.
Notes: Protocol number that must be matched
var redirect_vport_tag_id
Get redirect_vport_tag_id value.
Notes: VPort tag to which traffic will be redirected to, when ACL entry match criteria succeeds
This attribute is named `redirectVPortTagID` in VSD API.
var source_port
Get source_port value.
Notes: Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
var statistics
var stats_id
Get stats_id value.
Notes: The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
var stats_logging_enabled
Get stats_logging_enabled value.
Notes: Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
var uplink_preference
Get uplink_preference value.
Notes: Indicates the preferencial path selection for network traffic for this ACL - Default is Primary 1 and Secondary 2 when the attribute is applicable.
This attribute is named `uplinkPreference` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a IngressAdvFwdEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ingressadvfwdentrytemplate = NUIngressAdvFwdEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressAdvFwdEntryTemplate') >>> ingressadvfwdentrytemplate = NUIngressAdvFwdEntryTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a IngressAdvFwdEntryTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressadvfwdentrytemplate = NUIngressAdvFwdEntryTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressAdvFwdEntryTemplate')
>>> ingressadvfwdentrytemplate = NUIngressAdvFwdEntryTemplate(data=my_dict)
"""
super(NUIngressAdvFwdEntryTemplate, self).__init__()
# Read/Write Attributes
self._fc_override = None
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._redirect_vport_tag_id = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._uplink_preference = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="fc_override", remote_name="FCOverride", attribute_type=str, is_required=False, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redirect_vport_tag_id", remote_name="redirectVPortTagID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="uplink_preference", remote_name="uplinkPreference", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'PRIMARY_SECONDARY', u'SECONDARY', u'SECONDARY_PRIMARY', u'SYMMETRIC'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUIngressAdvFwdTemplate
Represents a IngressAdvFwdTemplate in the VSD
Notes: Defines the template for an Ingress Advanced Forwarding.
class NUIngressAdvFwdTemplate(NURESTObject):
""" Represents a IngressAdvFwdTemplate in the VSD
Notes:
Defines the template for an Ingress Advanced Forwarding.
"""
__rest_name__ = "ingressadvfwdtemplate"
__resource_name__ = "ingressadvfwdtemplates"
## Constants
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PRIORITY_TYPE_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PRIORITY_TYPE_TOP = "TOP"
CONST_PRIORITY_TYPE_BOTTOM = "BOTTOM"
def __init__(self, **kwargs):
""" Initializes a IngressAdvFwdTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressadvfwdtemplate = NUIngressAdvFwdTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressAdvFwdTemplate')
>>> ingressadvfwdtemplate = NUIngressAdvFwdTemplate(data=my_dict)
"""
super(NUIngressAdvFwdTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_entry_templates = NUIngressAdvFwdEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The name of the entity
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the entity
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def active(self):
""" Get active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
self._active = value
@property
def description(self):
""" Get description value.
Notes:
A description of the entity
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the entity
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def priority_type(self):
""" Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
return self._priority_type
@priority_type.setter
def priority_type(self, value):
""" Set priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
self._priority_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
Ancestors (in MRO)
- NUIngressAdvFwdTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_PRIORITY_TYPE_BOTTOM
var CONST_PRIORITY_TYPE_NONE
var CONST_PRIORITY_TYPE_TOP
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: If enabled, it means that this ACL or QOS entry is active
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the entity
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ingress_adv_fwd_entry_templates
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: The name of the entity
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var priority_type
Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a IngressAdvFwdTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ingressadvfwdtemplate = NUIngressAdvFwdTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressAdvFwdTemplate') >>> ingressadvfwdtemplate = NUIngressAdvFwdTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a IngressAdvFwdTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressadvfwdtemplate = NUIngressAdvFwdTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressAdvFwdTemplate')
>>> ingressadvfwdtemplate = NUIngressAdvFwdTemplate(data=my_dict)
"""
super(NUIngressAdvFwdTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._active = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_entry_templates = NUIngressAdvFwdEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.parent and self.rest_name != self.parent_type
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUIngressExternalServiceTemplate
Represents a IngressExternalServiceTemplate in the VSD
Notes: Defines the template for an Ingress External Service Acls.
class NUIngressExternalServiceTemplate(NURESTObject):
""" Represents a IngressExternalServiceTemplate in the VSD
Notes:
Defines the template for an Ingress External Service Acls.
"""
__rest_name__ = "ingressexternalservicetemplate"
__resource_name__ = "ingressexternalservicetemplates"
## Constants
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PRIORITY_TYPE_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PRIORITY_TYPE_TOP = "TOP"
CONST_PRIORITY_TYPE_BOTTOM = "BOTTOM"
def __init__(self, **kwargs):
""" Initializes a IngressExternalServiceTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressexternalservicetemplate = NUIngressExternalServiceTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressExternalServiceTemplate')
>>> ingressexternalservicetemplate = NUIngressExternalServiceTemplate(data=my_dict)
"""
super(NUIngressExternalServiceTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._active = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_template_entries = NUIngressExternalServiceTemplateEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
The name of the entity
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the entity
"""
self._name = value
@property
def active(self):
""" Get active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
self._active = value
@property
def description(self):
""" Get description value.
Notes:
A description of the entity
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the entity
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def priority_type(self):
""" Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
return self._priority_type
@priority_type.setter
def priority_type(self, value):
""" Set priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
"""
self._priority_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUIngressExternalServiceTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var CONST_PRIORITY_TYPE_BOTTOM
var CONST_PRIORITY_TYPE_NONE
var CONST_PRIORITY_TYPE_TOP
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: If enabled, it means that this ACL or QOS entry is active
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the entity
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ingress_external_service_template_entries
var jobs
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: The name of the entity
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes:
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var priority_type
Get priority_type value.
Notes:
This attribute is named `priorityType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a IngressExternalServiceTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ingressexternalservicetemplate = NUIngressExternalServiceTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressExternalServiceTemplate') >>> ingressexternalservicetemplate = NUIngressExternalServiceTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a IngressExternalServiceTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressexternalservicetemplate = NUIngressExternalServiceTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'IngressExternalServiceTemplate')
>>> ingressexternalservicetemplate = NUIngressExternalServiceTemplate(data=my_dict)
"""
super(NUIngressExternalServiceTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._active = None
self._description = None
self._entity_scope = None
self._policy_state = None
self._priority = None
self._priority_type = None
self._associated_live_entity_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="priority_type", remote_name="priorityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTTOM', u'NONE', u'TOP'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_template_entries = NUIngressExternalServiceTemplateEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUIngressExternalServiceTemplateEntry
Represents a IngressExternalServiceTemplateEntry in the VSD
Notes: Defines the template of Ingress External Service ACL entries
class NUIngressExternalServiceTemplateEntry(NURESTObject):
""" Represents a IngressExternalServiceTemplateEntry in the VSD
Notes:
Defines the template of Ingress External Service ACL entries
"""
__rest_name__ = "ingressexternalserviceentrytemplate"
__resource_name__ = "ingressexternalserviceentrytemplates"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ACTION_REDIRECT = "REDIRECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_NETWORK_TYPE_ENDPOINT_ZONE = "ENDPOINT_ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_LOCATION_TYPE_ANY = "ANY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_POLICY_STATE_DRAFT = "DRAFT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_NETWORK_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_NETWORK_TYPE_ENDPOINT_DOMAIN = "ENDPOINT_DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_NETWORK_TYPE_ANY = "ANY"
CONST_LOCATION_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_LOCATION_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_LOCATION_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_LOCATION_TYPE_REDIRECTIONTARGET = "REDIRECTIONTARGET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ACTION_DROP = "DROP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_NETWORK_TYPE_INTERNET_POLICYGROUP = "INTERNET_POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_LOCATION_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_NETWORK_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ACTION_FORWARD = "FORWARD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_NETWORK_TYPE_POLICYGROUP = "POLICYGROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_NETWORK_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_NETWORK_TYPE_ENDPOINT_SUBNET = "ENDPOINT_SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_POLICY_STATE_LIVE = "LIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
def __init__(self, **kwargs):
""" Initializes a IngressExternalServiceTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressexternalservicetemplateentry = NUIngressExternalServiceTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'IngressExternalServiceTemplateEntry')
>>> ingressexternalservicetemplateentry = NUIngressExternalServiceTemplateEntry(data=my_dict)
"""
super(NUIngressExternalServiceTemplateEntry, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._redirect_external_service_end_point_id = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redirect_external_service_end_point_id", remote_name="redirectExternalServiceEndPointID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dscp(self):
""" Get dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
return self._dscp
@dscp.setter
def dscp(self, value):
""" Set dscp value.
Notes:
DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
"""
self._dscp = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def action(self):
""" Get action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
"""
return self._action
@action.setter
def action(self, value):
""" Set action value.
Notes:
The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
"""
self._action = value
@property
def address_override(self):
""" Get address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
return self._address_override
@address_override.setter
def address_override(self, value):
""" Set address_override value.
Notes:
Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
"""
self._address_override = value
@property
def redirect_external_service_end_point_id(self):
""" Get redirect_external_service_end_point_id value.
Notes:
VPort tag to which traffic will be redirected to, when ACL entry match criteria succeeds
This attribute is named `redirectExternalServiceEndPointID` in VSD API.
"""
return self._redirect_external_service_end_point_id
@redirect_external_service_end_point_id.setter
def redirect_external_service_end_point_id(self, value):
""" Set redirect_external_service_end_point_id value.
Notes:
VPort tag to which traffic will be redirected to, when ACL entry match criteria succeeds
This attribute is named `redirectExternalServiceEndPointID` in VSD API.
"""
self._redirect_external_service_end_point_id = value
@property
def description(self):
""" Get description value.
Notes:
Description of the ACL entry
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the ACL entry
"""
self._description = value
@property
def destination_port(self):
""" Get destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
return self._destination_port
@destination_port.setter
def destination_port(self, value):
""" Set destination_port value.
Notes:
The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
"""
self._destination_port = value
@property
def network_id(self):
""" Get network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
return self._network_id
@network_id.setter
def network_id(self, value):
""" Set network_id value.
Notes:
The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
"""
self._network_id = value
@property
def network_type(self):
""" Get network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
return self._network_type
@network_type.setter
def network_type(self, value):
""" Set network_type value.
Notes:
Type of the source network.
This attribute is named `networkType` in VSD API.
"""
self._network_type = value
@property
def flow_logging_enabled(self):
""" Get flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
return self._flow_logging_enabled
@flow_logging_enabled.setter
def flow_logging_enabled(self, value):
""" Set flow_logging_enabled value.
Notes:
Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
"""
self._flow_logging_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location_id(self):
""" Get location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
return self._location_id
@location_id.setter
def location_id(self, value):
""" Set location_id value.
Notes:
The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
"""
self._location_id = value
@property
def location_type(self):
""" Get location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
return self._location_type
@location_type.setter
def location_type(self, value):
""" Set location_type value.
Notes:
Type of the location entity.
This attribute is named `locationType` in VSD API.
"""
self._location_type = value
@property
def policy_state(self):
""" Get policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
return self._policy_state
@policy_state.setter
def policy_state(self, value):
""" Set policy_state value.
Notes:
State of the policy.
This attribute is named `policyState` in VSD API.
"""
self._policy_state = value
@property
def source_port(self):
""" Get source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
return self._source_port
@source_port.setter
def source_port(self, value):
""" Set source_port value.
Notes:
Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
"""
self._source_port = value
@property
def priority(self):
""" Get priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
return self._priority
@priority.setter
def priority(self, value):
""" Set priority value.
Notes:
The priority of the ACL entry that determines the order of entries
"""
self._priority = value
@property
def protocol(self):
""" Get protocol value.
Notes:
Protocol number that must be matched
"""
return self._protocol
@protocol.setter
def protocol(self, value):
""" Set protocol value.
Notes:
Protocol number that must be matched
"""
self._protocol = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_live_entity_id(self):
""" Get associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
return self._associated_live_entity_id
@associated_live_entity_id.setter
def associated_live_entity_id(self, value):
""" Set associated_live_entity_id value.
Notes:
In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
"""
self._associated_live_entity_id = value
@property
def stats_id(self):
""" Get stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
return self._stats_id
@stats_id.setter
def stats_id(self, value):
""" Set stats_id value.
Notes:
The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
"""
self._stats_id = value
@property
def stats_logging_enabled(self):
""" Get stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
return self._stats_logging_enabled
@stats_logging_enabled.setter
def stats_logging_enabled(self, value):
""" Set stats_logging_enabled value.
Notes:
Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
"""
self._stats_logging_enabled = value
@property
def ether_type(self):
""" Get ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
return self._ether_type
@ether_type.setter
def ether_type(self, value):
""" Set ether_type value.
Notes:
Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
"""
self._ether_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUIngressExternalServiceTemplateEntry
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ACTION_DROP
var CONST_ACTION_FORWARD
var CONST_ACTION_REDIRECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_LOCATION_TYPE_ANY
var CONST_LOCATION_TYPE_POLICYGROUP
var CONST_LOCATION_TYPE_REDIRECTIONTARGET
var CONST_LOCATION_TYPE_SUBNET
var CONST_LOCATION_TYPE_VPORTTAG
var CONST_LOCATION_TYPE_ZONE
var CONST_NETWORK_TYPE_ANY
var CONST_NETWORK_TYPE_ENDPOINT_DOMAIN
var CONST_NETWORK_TYPE_ENDPOINT_SUBNET
var CONST_NETWORK_TYPE_ENDPOINT_ZONE
var CONST_NETWORK_TYPE_ENTERPRISE_NETWORK
var CONST_NETWORK_TYPE_INTERNET_POLICYGROUP
var CONST_NETWORK_TYPE_NETWORK_MACRO_GROUP
var CONST_NETWORK_TYPE_POLICYGROUP
var CONST_NETWORK_TYPE_PUBLIC_NETWORK
var CONST_NETWORK_TYPE_SUBNET
var CONST_NETWORK_TYPE_ZONE
var CONST_POLICY_STATE_DRAFT
var CONST_POLICY_STATE_LIVE
var resource_name
var rest_name
Instance variables
var action
Get action value.
Notes: The action of the ACL entry DROP or FORWARD or REDIRECT. Action REDIRECT is allowed only for IngressAdvancedForwardingEntry
var address_override
Get address_override value.
Notes: Overrides the source IP for Ingress and destination IP for Egress, macentries will use this adress as the match criteria.
This attribute is named `addressOverride` in VSD API.
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_live_entity_id
Get associated_live_entity_id value.
Notes: In the draft mode, the ACL entry refers to this LiveEntity. In non-drafted mode, this is null.
This attribute is named `associatedLiveEntityID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the ACL entry
var destination_port
Get destination_port value.
Notes: The destination port to be matched if protocol is UDP or TCP. Value should be either * or single port number or a port range
This attribute is named `destinationPort` in VSD API.
var dscp
Get dscp value.
Notes: DSCP match condition to be set in the rule. It is either * or from 0-63
This attribute is named `DSCP` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var ether_type
Get ether_type value.
Notes: Ether type of the packet to be matched. etherType can be * or a valid hexadecimal value
This attribute is named `etherType` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_logging_enabled
Get flow_logging_enabled value.
Notes: Is flow logging enabled for this particular template
This attribute is named `flowLoggingEnabled` in VSD API.
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location_id
Get location_id value.
Notes: The ID of the location entity (Subnet/Zone/VportTag)
This attribute is named `locationID` in VSD API.
var location_type
Get location_type value.
Notes: Type of the location entity.
This attribute is named `locationType` in VSD API.
var metadatas
var network_id
Get network_id value.
Notes: The destination network entity that is referenced(subnet/zone/macro)
This attribute is named `networkID` in VSD API.
var network_type
Get network_type value.
Notes: Type of the source network.
This attribute is named `networkType` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_state
Get policy_state value.
Notes: State of the policy.
This attribute is named `policyState` in VSD API.
var priority
Get priority value.
Notes: The priority of the ACL entry that determines the order of entries
var protocol
Get protocol value.
Notes: Protocol number that must be matched
var redirect_external_service_end_point_id
Get redirect_external_service_end_point_id value.
Notes: VPort tag to which traffic will be redirected to, when ACL entry match criteria succeeds
This attribute is named `redirectExternalServiceEndPointID` in VSD API.
var source_port
Get source_port value.
Notes: Source port to be matched if protocol is UDP or TCP. Value can be either * or single port number or a port range
This attribute is named `sourcePort` in VSD API.
var statistics
var stats_id
Get stats_id value.
Notes: The statsID that is created in the VSD and identifies this ACL Template Entry. This is auto-generated by VSD
This attribute is named `statsID` in VSD API.
var stats_logging_enabled
Get stats_logging_enabled value.
Notes: Is stats logging enabled for this particular template
This attribute is named `statsLoggingEnabled` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a IngressExternalServiceTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ingressexternalservicetemplateentry = NUIngressExternalServiceTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'IngressExternalServiceTemplateEntry') >>> ingressexternalservicetemplateentry = NUIngressExternalServiceTemplateEntry(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a IngressExternalServiceTemplateEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ingressexternalservicetemplateentry = NUIngressExternalServiceTemplateEntry(id=u'xxxx-xxx-xxx-xxx', name=u'IngressExternalServiceTemplateEntry')
>>> ingressexternalservicetemplateentry = NUIngressExternalServiceTemplateEntry(data=my_dict)
"""
super(NUIngressExternalServiceTemplateEntry, self).__init__()
# Read/Write Attributes
self._dscp = None
self._last_updated_by = None
self._action = None
self._address_override = None
self._redirect_external_service_end_point_id = None
self._description = None
self._destination_port = None
self._network_id = None
self._network_type = None
self._flow_logging_enabled = None
self._entity_scope = None
self._location_id = None
self._location_type = None
self._policy_state = None
self._source_port = None
self._priority = None
self._protocol = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_live_entity_id = None
self._stats_id = None
self._stats_logging_enabled = None
self._ether_type = None
self._external_id = None
self.expose_attribute(local_name="dscp", remote_name="DSCP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="action", remote_name="action", attribute_type=str, is_required=True, is_unique=False, choices=[u'DROP', u'FORWARD', u'REDIRECT'])
self.expose_attribute(local_name="address_override", remote_name="addressOverride", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redirect_external_service_end_point_id", remote_name="redirectExternalServiceEndPointID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_port", remote_name="destinationPort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="network_id", remote_name="networkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_type", remote_name="networkType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'ENDPOINT_DOMAIN', u'ENDPOINT_SUBNET', u'ENDPOINT_ZONE', u'ENTERPRISE_NETWORK', u'INTERNET_POLICYGROUP', u'NETWORK_MACRO_GROUP', u'POLICYGROUP', u'PUBLIC_NETWORK', u'SUBNET', u'ZONE'])
self.expose_attribute(local_name="flow_logging_enabled", remote_name="flowLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="location_type", remote_name="locationType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ANY', u'POLICYGROUP', u'REDIRECTIONTARGET', u'SUBNET', u'VPORTTAG', u'ZONE'])
self.expose_attribute(local_name="policy_state", remote_name="policyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DRAFT', u'LIVE'])
self.expose_attribute(local_name="source_port", remote_name="sourcePort", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="priority", remote_name="priority", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="protocol", remote_name="protocol", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_live_entity_id", remote_name="associatedLiveEntityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_id", remote_name="statsID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_logging_enabled", remote_name="statsLoggingEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ether_type", remote_name="etherType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUJob
Represents a Job in the VSD
Notes: Represents JOB entity. The job API accepts a command and parameters and executes the job and returns the results. Jobs API are typically used for long running tasks.
class NUJob(NURESTObject):
""" Represents a Job in the VSD
Notes:
Represents JOB entity. The job API accepts a command and parameters and executes the job and returns the results. Jobs API are typically used for long running tasks.
"""
__rest_name__ = "job"
__resource_name__ = "jobs"
## Constants
CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOC_ENTITY_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOC_ENTITY_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOC_ENTITY_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOC_ENTITY_TYPE_VLAN = "VLAN"
CONST_ASSOC_ENTITY_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOC_ENTITY_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_COMMAND_RETRIEVE_ACTIVE_NSGS = "RETRIEVE_ACTIVE_NSGS"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOC_ENTITY_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOC_ENTITY_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOC_ENTITY_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOC_ENTITY_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOC_ENTITY_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOC_ENTITY_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOC_ENTITY_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOC_ENTITY_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOC_ENTITY_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_ASSOC_ENTITY_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOC_ENTITY_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_COMMAND_EXPORT = "EXPORT"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOC_ENTITY_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOC_ENTITY_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOC_ENTITY_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOC_ENTITY_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOC_ENTITY_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_COMMAND_FORCE_KEYSERVER_VSD_RESYNC = "FORCE_KEYSERVER_VSD_RESYNC"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOC_ENTITY_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_ASSOC_ENTITY_TYPE_LOCATION = "LOCATION"
CONST_COMMAND_CERTIFICATE_NSG_REVOKE = "CERTIFICATE_NSG_REVOKE"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_COMMAND_NSG_REGISTRATION_INFO = "NSG_REGISTRATION_INFO"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOC_ENTITY_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_ASSOC_ENTITY_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_COMMAND_BATCH_GATEWAY_SECURED_DATAS = "BATCH_GATEWAY_SECURED_DATAS"
CONST_ASSOC_ENTITY_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_COMMAND_CLEAR_IPSEC_DATA = "CLEAR_IPSEC_DATA"
CONST_ASSOC_ENTITY_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
CONST_ASSOC_ENTITY_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOC_ENTITY_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOC_ENTITY_TYPE_APPD_TIER = "APPD_TIER"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOC_ENTITY_TYPE_PORT = "PORT"
CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOC_ENTITY_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOC_ENTITY_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOC_ENTITY_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOC_ENTITY_TYPE_SITE_RES = "SITE_RES"
CONST_ASSOC_ENTITY_TYPE_ALARM = "ALARM"
CONST_ASSOC_ENTITY_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ASSOC_ENTITY_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_COMMAND_RELOAD = "RELOAD"
CONST_ASSOC_ENTITY_TYPE_GROUP = "GROUP"
CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_COMMAND_NSG_NOTIFICATION_TEST = "NSG_NOTIFICATION_TEST"
CONST_ASSOC_ENTITY_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOC_ENTITY_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_COMMAND_FORCE_KEYSERVER_UPDATE = "FORCE_KEYSERVER_UPDATE"
CONST_ASSOC_ENTITY_TYPE_VSP = "VSP"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOC_ENTITY_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOC_ENTITY_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOC_ENTITY_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOC_ENTITY_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOC_ENTITY_TYPE_ZONE = "ZONE"
CONST_ASSOC_ENTITY_TYPE_VSC = "VSC"
CONST_ASSOC_ENTITY_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOC_ENTITY_TYPE_VSD = "VSD"
CONST_ASSOC_ENTITY_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_ASSOC_ENTITY_TYPE_GATEWAY = "GATEWAY"
CONST_COMMAND_APPLY_POLICY_CHANGES = "APPLY_POLICY_CHANGES"
CONST_ASSOC_ENTITY_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOC_ENTITY_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOC_ENTITY_TYPE_JOB = "JOB"
CONST_ASSOC_ENTITY_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOC_ENTITY_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOC_ENTITY_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_COMMAND_GATEWAY_AUDIT = "GATEWAY_AUDIT"
CONST_COMMAND_NOTIFY_NSG_REGISTRATION_TEST = "NOTIFY_NSG_REGISTRATION_TEST"
CONST_ASSOC_ENTITY_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOC_ENTITY_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOC_ENTITY_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOC_ENTITY_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOC_ENTITY_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_STATUS_FAILED = "FAILED"
CONST_ASSOC_ENTITY_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOC_ENTITY_TYPE_SUBNET = "SUBNET"
CONST_ASSOC_ENTITY_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOC_ENTITY_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOC_ENTITY_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOC_ENTITY_TYPE_USER = "USER"
CONST_COMMAND_KEYSERVER_NOTIFICATION_TEST = "KEYSERVER_NOTIFICATION_TEST"
CONST_ASSOC_ENTITY_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOC_ENTITY_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOC_ENTITY_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOC_ENTITY_TYPE_STATISTICS = "STATISTICS"
CONST_ASSOC_ENTITY_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_STATUS_SUCCESS = "SUCCESS"
CONST_ASSOC_ENTITY_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOC_ENTITY_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ASSOC_ENTITY_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOC_ENTITY_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOC_ENTITY_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOC_ENTITY_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOC_ENTITY_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOC_ENTITY_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOC_ENTITY_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOC_ENTITY_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOC_ENTITY_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOC_ENTITY_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOC_ENTITY_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOC_ENTITY_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOC_ENTITY_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOC_ENTITY_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOC_ENTITY_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_ASSOC_ENTITY_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOC_ENTITY_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOC_ENTITY_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_COMMAND_VCENTER_RECONNECT = "VCENTER_RECONNECT"
CONST_ASSOC_ENTITY_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_COMMAND_VCENTER_RELOAD = "VCENTER_RELOAD"
CONST_ASSOC_ENTITY_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_COMMAND_NOTIFY_NSG_REGISTRATION_ACK = "NOTIFY_NSG_REGISTRATION_ACK"
CONST_ASSOC_ENTITY_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOC_ENTITY_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOC_ENTITY_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOC_ENTITY_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_COMMAND_RELOAD_GEO_REDUNDANT_INFO = "RELOAD_GEO_REDUNDANT_INFO"
CONST_ASSOC_ENTITY_TYPE_VRS = "VRS"
CONST_ASSOC_ENTITY_TYPE_NSPORT = "NSPORT"
CONST_ASSOC_ENTITY_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOC_ENTITY_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOC_ENTITY_TYPE_HSC = "HSC"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_ASSOC_ENTITY_TYPE_VPORT = "VPORT"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOC_ENTITY_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOC_ENTITY_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOC_ENTITY_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOC_ENTITY_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOC_ENTITY_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOC_ENTITY_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOC_ENTITY_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOC_ENTITY_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ASSOC_ENTITY_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ASSOC_ENTITY_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOC_ENTITY_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOC_ENTITY_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOC_ENTITY_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOC_ENTITY_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOC_ENTITY_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_ASSOC_ENTITY_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOC_ENTITY_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOC_ENTITY_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOC_ENTITY_TYPE_SITE = "SITE"
CONST_COMMAND_BEGIN_POLICY_CHANGES = "BEGIN_POLICY_CHANGES"
CONST_ASSOC_ENTITY_TYPE_LICENSE = "LICENSE"
CONST_ASSOC_ENTITY_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOC_ENTITY_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOC_ENTITY_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOC_ENTITY_TYPE_METADATA = "METADATA"
CONST_ASSOC_ENTITY_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOC_ENTITY_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOC_ENTITY_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOC_ENTITY_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOC_ENTITY_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOC_ENTITY_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_ASSOC_ENTITY_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_COMMAND_NOTIFY_NSG_REGISTRATION = "NOTIFY_NSG_REGISTRATION"
CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_COMMAND_BATCH_CRUD_REQUEST = "BATCH_CRUD_REQUEST"
CONST_ASSOC_ENTITY_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOC_ENTITY_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_COMMAND_FORCE_KEYSERVER_UPDATE_ACK = "FORCE_KEYSERVER_UPDATE_ACK"
CONST_ASSOC_ENTITY_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOC_ENTITY_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOC_ENTITY_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ASSOC_ENTITY_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOC_ENTITY_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ASSOC_ENTITY_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOC_ENTITY_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_COMMAND_DISCARD_POLICY_CHANGES = "DISCARD_POLICY_CHANGES"
CONST_COMMAND_RELOAD_NSG_CONFIG = "RELOAD_NSG_CONFIG"
CONST_ASSOC_ENTITY_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_STATUS_RUNNING = "RUNNING"
CONST_ASSOC_ENTITY_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOC_ENTITY_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_COMMAND_IMPORT = "IMPORT"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOC_ENTITY_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOC_ENTITY_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOC_ENTITY_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOC_ENTITY_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_COMMAND_CERTIFICATE_NSG_RENEW = "CERTIFICATE_NSG_RENEW"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOC_ENTITY_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOC_ENTITY_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOC_ENTITY_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOC_ENTITY_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_ASSOC_ENTITY_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
def __init__(self, **kwargs):
""" Initializes a Job instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> job = NUJob(id=u'xxxx-xxx-xxx-xxx', name=u'Job')
>>> job = NUJob(data=my_dict)
"""
super(NUJob, self).__init__()
# Read/Write Attributes
self._parameters = None
self._last_updated_by = None
self._result = None
self._entity_scope = None
self._command = None
self._progress = None
self._assoc_entity_type = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="parameters", remote_name="parameters", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="result", remote_name="result", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="command", remote_name="command", attribute_type=str, is_required=True, is_unique=False, choices=[u'APPLY_POLICY_CHANGES', u'BATCH_CRUD_REQUEST', u'BATCH_GATEWAY_SECURED_DATAS', u'BEGIN_POLICY_CHANGES', u'CERTIFICATE_NSG_RENEW', u'CERTIFICATE_NSG_REVOKE', u'CLEAR_IPSEC_DATA', u'DISCARD_POLICY_CHANGES', u'EXPORT', u'FORCE_KEYSERVER_UPDATE', u'FORCE_KEYSERVER_UPDATE_ACK', u'FORCE_KEYSERVER_VSD_RESYNC', u'GATEWAY_AUDIT', u'IMPORT', u'KEYSERVER_NOTIFICATION_TEST', u'NOTIFY_NSG_REGISTRATION', u'NOTIFY_NSG_REGISTRATION_ACK', u'NOTIFY_NSG_REGISTRATION_TEST', u'NSG_NOTIFICATION_TEST', u'NSG_REGISTRATION_INFO', u'RELOAD', u'RELOAD_GEO_REDUNDANT_INFO', u'RELOAD_NSG_CONFIG', u'RETRIEVE_ACTIVE_NSGS', u'VCENTER_RECONNECT', u'VCENTER_RELOAD'])
self.expose_attribute(local_name="progress", remote_name="progress", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_entity_type", remote_name="assocEntityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILED', u'RUNNING', u'SUCCESS'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def parameters(self):
""" Get parameters value.
Notes:
Additional arguments required for the specific command. Differs based on types of command.
"""
return self._parameters
@parameters.setter
def parameters(self, value):
""" Set parameters value.
Notes:
Additional arguments required for the specific command. Differs based on types of command.
"""
self._parameters = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def result(self):
""" Get result value.
Notes:
Results from the execution of the job
"""
return self._result
@result.setter
def result(self, value):
""" Set result value.
Notes:
Results from the execution of the job
"""
self._result = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def command(self):
""" Get command value.
Notes:
Name of the command.
"""
return self._command
@command.setter
def command(self, value):
""" Set command value.
Notes:
Name of the command.
"""
self._command = value
@property
def progress(self):
""" Get progress value.
Notes:
Indicates the progress of the job as a faction. eg : 0.5 means 50% done.
"""
return self._progress
@progress.setter
def progress(self, value):
""" Set progress value.
Notes:
Indicates the progress of the job as a faction. eg : 0.5 means 50% done.
"""
self._progress = value
@property
def assoc_entity_type(self):
""" Get assoc_entity_type value.
Notes:
Entity with which this job is associated Refer to API section for supported types.
This attribute is named `assocEntityType` in VSD API.
"""
return self._assoc_entity_type
@assoc_entity_type.setter
def assoc_entity_type(self, value):
""" Set assoc_entity_type value.
Notes:
Entity with which this job is associated Refer to API section for supported types.
This attribute is named `assocEntityType` in VSD API.
"""
self._assoc_entity_type = value
@property
def status(self):
""" Get status value.
Notes:
Current status of the job. Possible values are RUNNING, FAILED, SUCCESS, .
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Current status of the job. Possible values are RUNNING, FAILED, SUCCESS, .
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUJob
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ASSOC_ENTITY_TYPE_ACLENTRY_LOCATION
var CONST_ASSOC_ENTITY_TYPE_ADDRESS_RANGE
var CONST_ASSOC_ENTITY_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOC_ENTITY_TYPE_ALARM
var CONST_ASSOC_ENTITY_TYPE_APPD_APPLICATION
var CONST_ASSOC_ENTITY_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOC_ENTITY_TYPE_APPD_FLOW
var CONST_ASSOC_ENTITY_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOC_ENTITY_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOC_ENTITY_TYPE_APPD_SERVICE
var CONST_ASSOC_ENTITY_TYPE_APPD_TIER
var CONST_ASSOC_ENTITY_TYPE_APPLICATION
var CONST_ASSOC_ENTITY_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOC_ENTITY_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOC_ENTITY_TYPE_BGPPEER
var CONST_ASSOC_ENTITY_TYPE_BOOTSTRAP
var CONST_ASSOC_ENTITY_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOC_ENTITY_TYPE_BRIDGEINTERFACE
var CONST_ASSOC_ENTITY_TYPE_CERTIFICATE
var CONST_ASSOC_ENTITY_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOC_ENTITY_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOC_ENTITY_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOC_ENTITY_TYPE_DC_CONFIG
var CONST_ASSOC_ENTITY_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOC_ENTITY_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_DHCP_OPTION
var CONST_ASSOC_ENTITY_TYPE_DISKSTATS
var CONST_ASSOC_ENTITY_TYPE_DOMAIN
var CONST_ASSOC_ENTITY_TYPE_DOMAIN_CONFIG
var CONST_ASSOC_ENTITY_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOC_ENTITY_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOC_ENTITY_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL
var CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOC_ENTITY_TYPE_EGRESS_QOS_MR
var CONST_ASSOC_ENTITY_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOC_ENTITY_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOC_ENTITY_TYPE_ENDPOINT
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOC_ENTITY_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOC_ENTITY_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOC_ENTITY_TYPE_ESI_SEQUENCENO
var CONST_ASSOC_ENTITY_TYPE_EVENT_LOG
var CONST_ASSOC_ENTITY_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOC_ENTITY_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOC_ENTITY_TYPE_EXPORTIMPORT
var CONST_ASSOC_ENTITY_TYPE_EXTERNAL_SERVICE
var CONST_ASSOC_ENTITY_TYPE_FLOATINGIP
var CONST_ASSOC_ENTITY_TYPE_FLOATINGIP_ACL
var CONST_ASSOC_ENTITY_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOC_ENTITY_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOC_ENTITY_TYPE_GATEWAY
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_CONFIG
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOC_ENTITY_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_GEO_VM_EVENT
var CONST_ASSOC_ENTITY_TYPE_GEO_VM_REQ
var CONST_ASSOC_ENTITY_TYPE_GEO_VM_RES
var CONST_ASSOC_ENTITY_TYPE_GROUP
var CONST_ASSOC_ENTITY_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOC_ENTITY_TYPE_HEALTH_REQ
var CONST_ASSOC_ENTITY_TYPE_HOSTINTERFACE
var CONST_ASSOC_ENTITY_TYPE_HSC
var CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOC_ENTITY_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOC_ENTITY_TYPE_IP_BINDING
var CONST_ASSOC_ENTITY_TYPE_JOB
var CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MEMBER
var CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR
var CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOC_ENTITY_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOC_ENTITY_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOC_ENTITY_TYPE_L2DOMAIN
var CONST_ASSOC_ENTITY_TYPE_L2DOMAIN_SHARED
var CONST_ASSOC_ENTITY_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_LDAP_CONFIG
var CONST_ASSOC_ENTITY_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOC_ENTITY_TYPE_LICENSE
var CONST_ASSOC_ENTITY_TYPE_LOCATION
var CONST_ASSOC_ENTITY_TYPE_MC_CHANNEL_MAP
var CONST_ASSOC_ENTITY_TYPE_MC_LIST
var CONST_ASSOC_ENTITY_TYPE_MC_RANGE
var CONST_ASSOC_ENTITY_TYPE_METADATA
var CONST_ASSOC_ENTITY_TYPE_METADATA_TAG
var CONST_ASSOC_ENTITY_TYPE_MIRROR_DESTINATION
var CONST_ASSOC_ENTITY_TYPE_MONITORING_PORT
var CONST_ASSOC_ENTITY_TYPE_MULTI_NIC_VPORT
var CONST_ASSOC_ENTITY_TYPE_NATMAPENTRY
var CONST_ASSOC_ENTITY_TYPE_NETWORK_ELEMENT
var CONST_ASSOC_ENTITY_TYPE_NETWORK_LAYOUT
var CONST_ASSOC_ENTITY_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOC_ENTITY_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOC_ENTITY_TYPE_NEXT_HOP_RESP
var CONST_ASSOC_ENTITY_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOC_ENTITY_TYPE_NSGATEWAY
var CONST_ASSOC_ENTITY_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOC_ENTITY_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_NSG_NOTIFICATION
var CONST_ASSOC_ENTITY_TYPE_NSPORT
var CONST_ASSOC_ENTITY_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOC_ENTITY_TYPE_NSPORT_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOC_ENTITY_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOC_ENTITY_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_PATNATPOOL
var CONST_ASSOC_ENTITY_TYPE_PERMISSION
var CONST_ASSOC_ENTITY_TYPE_PERMITTED_ACTION
var CONST_ASSOC_ENTITY_TYPE_POLICING_POLICY
var CONST_ASSOC_ENTITY_TYPE_POLICY_DECISION
var CONST_ASSOC_ENTITY_TYPE_POLICY_GROUP
var CONST_ASSOC_ENTITY_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_PORT
var CONST_ASSOC_ENTITY_TYPE_PORT_MR
var CONST_ASSOC_ENTITY_TYPE_PORT_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_PUBLIC_NETWORK
var CONST_ASSOC_ENTITY_TYPE_QOS_PRIMITIVE
var CONST_ASSOC_ENTITY_TYPE_RATE_LIMITER
var CONST_ASSOC_ENTITY_TYPE_RD_SEQUENCENO
var CONST_ASSOC_ENTITY_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOC_ENTITY_TYPE_RTRD_ENTITY
var CONST_ASSOC_ENTITY_TYPE_RTRD_SEQUENCENO
var CONST_ASSOC_ENTITY_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOC_ENTITY_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOC_ENTITY_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOC_ENTITY_TYPE_SHAPING_POLICY
var CONST_ASSOC_ENTITY_TYPE_SHARED_RESOURCE
var CONST_ASSOC_ENTITY_TYPE_SITE
var CONST_ASSOC_ENTITY_TYPE_SITE_REQ
var CONST_ASSOC_ENTITY_TYPE_SITE_RES
var CONST_ASSOC_ENTITY_TYPE_STATIC_ROUTE
var CONST_ASSOC_ENTITY_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOC_ENTITY_TYPE_STATISTICS
var CONST_ASSOC_ENTITY_TYPE_STATSSERVER
var CONST_ASSOC_ENTITY_TYPE_STATS_COLLECTOR
var CONST_ASSOC_ENTITY_TYPE_STATS_POLICY
var CONST_ASSOC_ENTITY_TYPE_STATS_TCA
var CONST_ASSOC_ENTITY_TYPE_SUBNET
var CONST_ASSOC_ENTITY_TYPE_SUBNET_ENTRY
var CONST_ASSOC_ENTITY_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOC_ENTITY_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOC_ENTITY_TYPE_SUBNET_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_SYSTEM_CONFIG
var CONST_ASSOC_ENTITY_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOC_ENTITY_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOC_ENTITY_TYPE_SYSTEM_MONITORING
var CONST_ASSOC_ENTITY_TYPE_UNSUPPORTED
var CONST_ASSOC_ENTITY_TYPE_UPLINK_RD
var CONST_ASSOC_ENTITY_TYPE_USER
var CONST_ASSOC_ENTITY_TYPE_VIRTUAL_IP
var CONST_ASSOC_ENTITY_TYPE_VIRTUAL_MACHINE
var CONST_ASSOC_ENTITY_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOC_ENTITY_TYPE_VLAN
var CONST_ASSOC_ENTITY_TYPE_VLAN_TEMPLATE
var CONST_ASSOC_ENTITY_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOC_ENTITY_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOC_ENTITY_TYPE_VM_DESCRIPTION
var CONST_ASSOC_ENTITY_TYPE_VM_INTERFACE
var CONST_ASSOC_ENTITY_TYPE_VNID_SEQUENCENO
var CONST_ASSOC_ENTITY_TYPE_VPN_CONNECT
var CONST_ASSOC_ENTITY_TYPE_VPORT
var CONST_ASSOC_ENTITY_TYPE_VPORTTAG
var CONST_ASSOC_ENTITY_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOC_ENTITY_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOC_ENTITY_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOC_ENTITY_TYPE_VPORT_MIRROR
var CONST_ASSOC_ENTITY_TYPE_VPORT_TAG_BASE
var CONST_ASSOC_ENTITY_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOC_ENTITY_TYPE_VRS
var CONST_ASSOC_ENTITY_TYPE_VSC
var CONST_ASSOC_ENTITY_TYPE_VSD
var CONST_ASSOC_ENTITY_TYPE_VSD_COMPONENT
var CONST_ASSOC_ENTITY_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOC_ENTITY_TYPE_VSP
var CONST_ASSOC_ENTITY_TYPE_WAN_SERVICE
var CONST_ASSOC_ENTITY_TYPE_ZONE
var CONST_ASSOC_ENTITY_TYPE_ZONE_TEMPLATE
var CONST_COMMAND_APPLY_POLICY_CHANGES
var CONST_COMMAND_BATCH_CRUD_REQUEST
var CONST_COMMAND_BATCH_GATEWAY_SECURED_DATAS
var CONST_COMMAND_BEGIN_POLICY_CHANGES
var CONST_COMMAND_CERTIFICATE_NSG_RENEW
var CONST_COMMAND_CERTIFICATE_NSG_REVOKE
var CONST_COMMAND_CLEAR_IPSEC_DATA
var CONST_COMMAND_DISCARD_POLICY_CHANGES
var CONST_COMMAND_EXPORT
var CONST_COMMAND_FORCE_KEYSERVER_UPDATE
var CONST_COMMAND_FORCE_KEYSERVER_UPDATE_ACK
var CONST_COMMAND_FORCE_KEYSERVER_VSD_RESYNC
var CONST_COMMAND_GATEWAY_AUDIT
var CONST_COMMAND_IMPORT
var CONST_COMMAND_KEYSERVER_NOTIFICATION_TEST
var CONST_COMMAND_NOTIFY_NSG_REGISTRATION
var CONST_COMMAND_NOTIFY_NSG_REGISTRATION_ACK
var CONST_COMMAND_NOTIFY_NSG_REGISTRATION_TEST
var CONST_COMMAND_NSG_NOTIFICATION_TEST
var CONST_COMMAND_NSG_REGISTRATION_INFO
var CONST_COMMAND_RELOAD
var CONST_COMMAND_RELOAD_GEO_REDUNDANT_INFO
var CONST_COMMAND_RELOAD_NSG_CONFIG
var CONST_COMMAND_RETRIEVE_ACTIVE_NSGS
var CONST_COMMAND_VCENTER_RECONNECT
var CONST_COMMAND_VCENTER_RELOAD
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_STATUS_FAILED
var CONST_STATUS_RUNNING
var CONST_STATUS_SUCCESS
var resource_name
var rest_name
Instance variables
var assoc_entity_type
Get assoc_entity_type value.
Notes: Entity with which this job is associated Refer to API section for supported types.
This attribute is named `assocEntityType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var command
Get command value.
Notes: Name of the command.
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parameters
Get parameters value.
Notes: Additional arguments required for the specific command. Differs based on types of command.
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var progress
Get progress value.
Notes: Indicates the progress of the job as a faction. eg : 0.5 means 50% done.
var result
Get result value.
Notes: Results from the execution of the job
var status
Get status value.
Notes: Current status of the job. Possible values are RUNNING, FAILED, SUCCESS, .
Methods
def __init__(
self, **kwargs)
Initializes a Job instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> job = NUJob(id=u'xxxx-xxx-xxx-xxx', name=u'Job') >>> job = NUJob(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Job instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> job = NUJob(id=u'xxxx-xxx-xxx-xxx', name=u'Job')
>>> job = NUJob(data=my_dict)
"""
super(NUJob, self).__init__()
# Read/Write Attributes
self._parameters = None
self._last_updated_by = None
self._result = None
self._entity_scope = None
self._command = None
self._progress = None
self._assoc_entity_type = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="parameters", remote_name="parameters", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="result", remote_name="result", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="command", remote_name="command", attribute_type=str, is_required=True, is_unique=False, choices=[u'APPLY_POLICY_CHANGES', u'BATCH_CRUD_REQUEST', u'BATCH_GATEWAY_SECURED_DATAS', u'BEGIN_POLICY_CHANGES', u'CERTIFICATE_NSG_RENEW', u'CERTIFICATE_NSG_REVOKE', u'CLEAR_IPSEC_DATA', u'DISCARD_POLICY_CHANGES', u'EXPORT', u'FORCE_KEYSERVER_UPDATE', u'FORCE_KEYSERVER_UPDATE_ACK', u'FORCE_KEYSERVER_VSD_RESYNC', u'GATEWAY_AUDIT', u'IMPORT', u'KEYSERVER_NOTIFICATION_TEST', u'NOTIFY_NSG_REGISTRATION', u'NOTIFY_NSG_REGISTRATION_ACK', u'NOTIFY_NSG_REGISTRATION_TEST', u'NSG_NOTIFICATION_TEST', u'NSG_REGISTRATION_INFO', u'RELOAD', u'RELOAD_GEO_REDUNDANT_INFO', u'RELOAD_NSG_CONFIG', u'RETRIEVE_ACTIVE_NSGS', u'VCENTER_RECONNECT', u'VCENTER_RELOAD'])
self.expose_attribute(local_name="progress", remote_name="progress", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_entity_type", remote_name="assocEntityType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILED', u'RUNNING', u'SUCCESS'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUKeyServerMember
Represents a KeyServerMember in the VSD
Notes: Represents a KeyServer
class NUKeyServerMember(NURESTObject):
""" Represents a KeyServerMember in the VSD
Notes:
Represents a KeyServer
"""
__rest_name__ = "keyservermember"
__resource_name__ = "keyservermembers"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a KeyServerMember instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermember = NUKeyServerMember(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMember')
>>> keyservermember = NUKeyServerMember(data=my_dict)
"""
super(NUKeyServerMember, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._pem_encoded = None
self._certificate_serial_number = None
self._entity_scope = None
self._fqdn = None
self._issuer_dn = None
self._subject_dn = None
self._public_key = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="pem_encoded", remote_name="pemEncoded", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="certificate_serial_number", remote_name="certificateSerialNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="fqdn", remote_name="fqdn", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="issuer_dn", remote_name="issuerDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subject_dn", remote_name="subjectDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_key", remote_name="publicKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def pem_encoded(self):
""" Get pem_encoded value.
Notes:
PEM Encoded Certificate
This attribute is named `pemEncoded` in VSD API.
"""
return self._pem_encoded
@pem_encoded.setter
def pem_encoded(self, value):
""" Set pem_encoded value.
Notes:
PEM Encoded Certificate
This attribute is named `pemEncoded` in VSD API.
"""
self._pem_encoded = value
@property
def certificate_serial_number(self):
""" Get certificate_serial_number value.
Notes:
Certificate serial number associated to the keyserver private key which it is currently signing with
This attribute is named `certificateSerialNumber` in VSD API.
"""
return self._certificate_serial_number
@certificate_serial_number.setter
def certificate_serial_number(self, value):
""" Set certificate_serial_number value.
Notes:
Certificate serial number associated to the keyserver private key which it is currently signing with
This attribute is named `certificateSerialNumber` in VSD API.
"""
self._certificate_serial_number = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def fqdn(self):
""" Get fqdn value.
Notes:
FQDN of the keyserver member
"""
return self._fqdn
@fqdn.setter
def fqdn(self, value):
""" Set fqdn value.
Notes:
FQDN of the keyserver member
"""
self._fqdn = value
@property
def issuer_dn(self):
""" Get issuer_dn value.
Notes:
Issuer DN
This attribute is named `issuerDN` in VSD API.
"""
return self._issuer_dn
@issuer_dn.setter
def issuer_dn(self, value):
""" Set issuer_dn value.
Notes:
Issuer DN
This attribute is named `issuerDN` in VSD API.
"""
self._issuer_dn = value
@property
def subject_dn(self):
""" Get subject_dn value.
Notes:
Subject DN
This attribute is named `subjectDN` in VSD API.
"""
return self._subject_dn
@subject_dn.setter
def subject_dn(self, value):
""" Set subject_dn value.
Notes:
Subject DN
This attribute is named `subjectDN` in VSD API.
"""
self._subject_dn = value
@property
def public_key(self):
""" Get public_key value.
Notes:
Public Key
This attribute is named `publicKey` in VSD API.
"""
return self._public_key
@public_key.setter
def public_key(self, value):
""" Set public_key value.
Notes:
Public Key
This attribute is named `publicKey` in VSD API.
"""
self._public_key = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUKeyServerMember
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var certificate_serial_number
Get certificate_serial_number value.
Notes: Certificate serial number associated to the keyserver private key which it is currently signing with
This attribute is named `certificateSerialNumber` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var fqdn
Get fqdn value.
Notes: FQDN of the keyserver member
var global_metadatas
var id
Get object id
var issuer_dn
Get issuer_dn value.
Notes: Issuer DN
This attribute is named `issuerDN` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var pem_encoded
Get pem_encoded value.
Notes: PEM Encoded Certificate
This attribute is named `pemEncoded` in VSD API.
var public_key
Get public_key value.
Notes: Public Key
This attribute is named `publicKey` in VSD API.
var subject_dn
Get subject_dn value.
Notes: Subject DN
This attribute is named `subjectDN` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a KeyServerMember instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> keyservermember = NUKeyServerMember(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMember') >>> keyservermember = NUKeyServerMember(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a KeyServerMember instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermember = NUKeyServerMember(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMember')
>>> keyservermember = NUKeyServerMember(data=my_dict)
"""
super(NUKeyServerMember, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._pem_encoded = None
self._certificate_serial_number = None
self._entity_scope = None
self._fqdn = None
self._issuer_dn = None
self._subject_dn = None
self._public_key = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="pem_encoded", remote_name="pemEncoded", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="certificate_serial_number", remote_name="certificateSerialNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="fqdn", remote_name="fqdn", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="issuer_dn", remote_name="issuerDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subject_dn", remote_name="subjectDN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_key", remote_name="publicKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUKeyServerMonitor
Represents a KeyServerMonitor in the VSD
Notes: Represents a Keyserver Monitor Snapshot.
class NUKeyServerMonitor(NURESTObject):
""" Represents a KeyServerMonitor in the VSD
Notes:
Represents a Keyserver Monitor Snapshot.
"""
__rest_name__ = "keyservermonitor"
__resource_name__ = "keyservermonitors"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitor instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitor = NUKeyServerMonitor(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitor')
>>> keyservermonitor = NUKeyServerMonitor(data=my_dict)
"""
super(NUKeyServerMonitor, self).__init__()
# Read/Write Attributes
self._last_update_time = None
self._last_updated_by = None
self._gateway_secured_data_record_count = None
self._keyserver_monitor_encrypted_sek_count = None
self._keyserver_monitor_encrypted_seed_count = None
self._keyserver_monitor_sek_count = None
self._keyserver_monitor_seed_count = None
self._enterprise_secured_data_record_count = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_update_time", remote_name="lastUpdateTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_secured_data_record_count", remote_name="gatewaySecuredDataRecordCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_encrypted_sek_count", remote_name="keyserverMonitorEncryptedSEKCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_encrypted_seed_count", remote_name="keyserverMonitorEncryptedSeedCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_sek_count", remote_name="keyserverMonitorSEKCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_seed_count", remote_name="keyserverMonitorSeedCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_secured_data_record_count", remote_name="enterpriseSecuredDataRecordCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_encrypted_seeds = NUKeyServerMonitorEncryptedSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_seeds = NUKeyServerMonitorSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_seks = NUKeyServerMonitorSEKsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_update_time(self):
""" Get last_update_time value.
Notes:
The time the latest SEK or Seed was created/removed (milliseconds since epoch)
This attribute is named `lastUpdateTime` in VSD API.
"""
return self._last_update_time
@last_update_time.setter
def last_update_time(self, value):
""" Set last_update_time value.
Notes:
The time the latest SEK or Seed was created/removed (milliseconds since epoch)
This attribute is named `lastUpdateTime` in VSD API.
"""
self._last_update_time = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_secured_data_record_count(self):
""" Get gateway_secured_data_record_count value.
Notes:
Total number of Gateway Secured Data records
This attribute is named `gatewaySecuredDataRecordCount` in VSD API.
"""
return self._gateway_secured_data_record_count
@gateway_secured_data_record_count.setter
def gateway_secured_data_record_count(self, value):
""" Set gateway_secured_data_record_count value.
Notes:
Total number of Gateway Secured Data records
This attribute is named `gatewaySecuredDataRecordCount` in VSD API.
"""
self._gateway_secured_data_record_count = value
@property
def keyserver_monitor_encrypted_sek_count(self):
""" Get keyserver_monitor_encrypted_sek_count value.
Notes:
Total number of Keyserver Monitor Encrypted SEK records
This attribute is named `keyserverMonitorEncryptedSEKCount` in VSD API.
"""
return self._keyserver_monitor_encrypted_sek_count
@keyserver_monitor_encrypted_sek_count.setter
def keyserver_monitor_encrypted_sek_count(self, value):
""" Set keyserver_monitor_encrypted_sek_count value.
Notes:
Total number of Keyserver Monitor Encrypted SEK records
This attribute is named `keyserverMonitorEncryptedSEKCount` in VSD API.
"""
self._keyserver_monitor_encrypted_sek_count = value
@property
def keyserver_monitor_encrypted_seed_count(self):
""" Get keyserver_monitor_encrypted_seed_count value.
Notes:
Total number of Keyserver Monitor Encrypted Seed records
This attribute is named `keyserverMonitorEncryptedSeedCount` in VSD API.
"""
return self._keyserver_monitor_encrypted_seed_count
@keyserver_monitor_encrypted_seed_count.setter
def keyserver_monitor_encrypted_seed_count(self, value):
""" Set keyserver_monitor_encrypted_seed_count value.
Notes:
Total number of Keyserver Monitor Encrypted Seed records
This attribute is named `keyserverMonitorEncryptedSeedCount` in VSD API.
"""
self._keyserver_monitor_encrypted_seed_count = value
@property
def keyserver_monitor_sek_count(self):
""" Get keyserver_monitor_sek_count value.
Notes:
Total number of Keyserver Monitor SEK records
This attribute is named `keyserverMonitorSEKCount` in VSD API.
"""
return self._keyserver_monitor_sek_count
@keyserver_monitor_sek_count.setter
def keyserver_monitor_sek_count(self, value):
""" Set keyserver_monitor_sek_count value.
Notes:
Total number of Keyserver Monitor SEK records
This attribute is named `keyserverMonitorSEKCount` in VSD API.
"""
self._keyserver_monitor_sek_count = value
@property
def keyserver_monitor_seed_count(self):
""" Get keyserver_monitor_seed_count value.
Notes:
Total number of Keyserver Monitor Seed records
This attribute is named `keyserverMonitorSeedCount` in VSD API.
"""
return self._keyserver_monitor_seed_count
@keyserver_monitor_seed_count.setter
def keyserver_monitor_seed_count(self, value):
""" Set keyserver_monitor_seed_count value.
Notes:
Total number of Keyserver Monitor Seed records
This attribute is named `keyserverMonitorSeedCount` in VSD API.
"""
self._keyserver_monitor_seed_count = value
@property
def enterprise_secured_data_record_count(self):
""" Get enterprise_secured_data_record_count value.
Notes:
Total number of Enterprise Secured Data records
This attribute is named `enterpriseSecuredDataRecordCount` in VSD API.
"""
return self._enterprise_secured_data_record_count
@enterprise_secured_data_record_count.setter
def enterprise_secured_data_record_count(self, value):
""" Set enterprise_secured_data_record_count value.
Notes:
Total number of Enterprise Secured Data records
This attribute is named `enterpriseSecuredDataRecordCount` in VSD API.
"""
self._enterprise_secured_data_record_count = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUKeyServerMonitor
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var enterprise_secured_data_record_count
Get enterprise_secured_data_record_count value.
Notes: Total number of Enterprise Secured Data records
This attribute is named `enterpriseSecuredDataRecordCount` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_secured_data_record_count
Get gateway_secured_data_record_count value.
Notes: Total number of Gateway Secured Data records
This attribute is named `gatewaySecuredDataRecordCount` in VSD API.
var global_metadatas
var id
Get object id
var key_server_monitor_encrypted_seeds
var key_server_monitor_seeds
var key_server_monitor_seks
var keyserver_monitor_encrypted_seed_count
Get keyserver_monitor_encrypted_seed_count value.
Notes: Total number of Keyserver Monitor Encrypted Seed records
This attribute is named `keyserverMonitorEncryptedSeedCount` in VSD API.
var keyserver_monitor_encrypted_sek_count
Get keyserver_monitor_encrypted_sek_count value.
Notes: Total number of Keyserver Monitor Encrypted SEK records
This attribute is named `keyserverMonitorEncryptedSEKCount` in VSD API.
var keyserver_monitor_seed_count
Get keyserver_monitor_seed_count value.
Notes: Total number of Keyserver Monitor Seed records
This attribute is named `keyserverMonitorSeedCount` in VSD API.
var keyserver_monitor_sek_count
Get keyserver_monitor_sek_count value.
Notes: Total number of Keyserver Monitor SEK records
This attribute is named `keyserverMonitorSEKCount` in VSD API.
var last_update_time
Get last_update_time value.
Notes: The time the latest SEK or Seed was created/removed (milliseconds since epoch)
This attribute is named `lastUpdateTime` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a KeyServerMonitor instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> keyservermonitor = NUKeyServerMonitor(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitor') >>> keyservermonitor = NUKeyServerMonitor(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitor instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitor = NUKeyServerMonitor(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitor')
>>> keyservermonitor = NUKeyServerMonitor(data=my_dict)
"""
super(NUKeyServerMonitor, self).__init__()
# Read/Write Attributes
self._last_update_time = None
self._last_updated_by = None
self._gateway_secured_data_record_count = None
self._keyserver_monitor_encrypted_sek_count = None
self._keyserver_monitor_encrypted_seed_count = None
self._keyserver_monitor_sek_count = None
self._keyserver_monitor_seed_count = None
self._enterprise_secured_data_record_count = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_update_time", remote_name="lastUpdateTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_secured_data_record_count", remote_name="gatewaySecuredDataRecordCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_encrypted_sek_count", remote_name="keyserverMonitorEncryptedSEKCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_encrypted_seed_count", remote_name="keyserverMonitorEncryptedSeedCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_sek_count", remote_name="keyserverMonitorSEKCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="keyserver_monitor_seed_count", remote_name="keyserverMonitorSeedCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_secured_data_record_count", remote_name="enterpriseSecuredDataRecordCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_encrypted_seeds = NUKeyServerMonitorEncryptedSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_seeds = NUKeyServerMonitorSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_seks = NUKeyServerMonitorSEKsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUKeyServerMonitorEncryptedSeed
Represents a KeyServerMonitorEncryptedSeed in the VSD
Notes: Represents a Keyserver Monitor Encrypted Seed Snapshot.
class NUKeyServerMonitorEncryptedSeed(NURESTObject):
""" Represents a KeyServerMonitorEncryptedSeed in the VSD
Notes:
Represents a Keyserver Monitor Encrypted Seed Snapshot.
"""
__rest_name__ = "keyservermonitorencryptedseed"
__resource_name__ = "keyservermonitorencryptedseeds"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitorEncryptedSeed instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitorencryptedseed = NUKeyServerMonitorEncryptedSeed(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorEncryptedSeed')
>>> keyservermonitorencryptedseed = NUKeyServerMonitorEncryptedSeed(data=my_dict)
"""
super(NUKeyServerMonitorEncryptedSeed, self).__init__()
# Read/Write Attributes
self._sek_creation_time = None
self._last_updated_by = None
self._key_server_certificate_serial_number = None
self._enterprise_secured_data_id = None
self._entity_scope = None
self._associated_key_server_monitor_sek_creation_time = None
self._associated_key_server_monitor_sekid = None
self._associated_key_server_monitor_seed_creation_time = None
self._associated_key_server_monitor_seed_id = None
self._external_id = None
self.expose_attribute(local_name="sek_creation_time", remote_name="SEKCreationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="key_server_certificate_serial_number", remote_name="keyServerCertificateSerialNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_secured_data_id", remote_name="enterpriseSecuredDataID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_key_server_monitor_sek_creation_time", remote_name="associatedKeyServerMonitorSEKCreationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_key_server_monitor_sekid", remote_name="associatedKeyServerMonitorSEKID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_key_server_monitor_seed_creation_time", remote_name="associatedKeyServerMonitorSeedCreationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_key_server_monitor_seed_id", remote_name="associatedKeyServerMonitorSeedID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def sek_creation_time(self):
""" Get sek_creation_time value.
Notes:
SEK Creation Time
This attribute is named `SEKCreationTime` in VSD API.
"""
return self._sek_creation_time
@sek_creation_time.setter
def sek_creation_time(self, value):
""" Set sek_creation_time value.
Notes:
SEK Creation Time
This attribute is named `SEKCreationTime` in VSD API.
"""
self._sek_creation_time = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def key_server_certificate_serial_number(self):
""" Get key_server_certificate_serial_number value.
Notes:
KeyServer Certificate Serial Number
This attribute is named `keyServerCertificateSerialNumber` in VSD API.
"""
return self._key_server_certificate_serial_number
@key_server_certificate_serial_number.setter
def key_server_certificate_serial_number(self, value):
""" Set key_server_certificate_serial_number value.
Notes:
KeyServer Certificate Serial Number
This attribute is named `keyServerCertificateSerialNumber` in VSD API.
"""
self._key_server_certificate_serial_number = value
@property
def enterprise_secured_data_id(self):
""" Get enterprise_secured_data_id value.
Notes:
Enterprise Secured ID record this monitor represents
This attribute is named `enterpriseSecuredDataID` in VSD API.
"""
return self._enterprise_secured_data_id
@enterprise_secured_data_id.setter
def enterprise_secured_data_id(self, value):
""" Set enterprise_secured_data_id value.
Notes:
Enterprise Secured ID record this monitor represents
This attribute is named `enterpriseSecuredDataID` in VSD API.
"""
self._enterprise_secured_data_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_key_server_monitor_sek_creation_time(self):
""" Get associated_key_server_monitor_sek_creation_time value.
Notes:
The creation time of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSEKCreationTime` in VSD API.
"""
return self._associated_key_server_monitor_sek_creation_time
@associated_key_server_monitor_sek_creation_time.setter
def associated_key_server_monitor_sek_creation_time(self, value):
""" Set associated_key_server_monitor_sek_creation_time value.
Notes:
The creation time of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSEKCreationTime` in VSD API.
"""
self._associated_key_server_monitor_sek_creation_time = value
@property
def associated_key_server_monitor_sekid(self):
""" Get associated_key_server_monitor_sekid value.
Notes:
The ID of the associated KeyServer Monitor SEK ID
This attribute is named `associatedKeyServerMonitorSEKID` in VSD API.
"""
return self._associated_key_server_monitor_sekid
@associated_key_server_monitor_sekid.setter
def associated_key_server_monitor_sekid(self, value):
""" Set associated_key_server_monitor_sekid value.
Notes:
The ID of the associated KeyServer Monitor SEK ID
This attribute is named `associatedKeyServerMonitorSEKID` in VSD API.
"""
self._associated_key_server_monitor_sekid = value
@property
def associated_key_server_monitor_seed_creation_time(self):
""" Get associated_key_server_monitor_seed_creation_time value.
Notes:
The creation time of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSeedCreationTime` in VSD API.
"""
return self._associated_key_server_monitor_seed_creation_time
@associated_key_server_monitor_seed_creation_time.setter
def associated_key_server_monitor_seed_creation_time(self, value):
""" Set associated_key_server_monitor_seed_creation_time value.
Notes:
The creation time of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSeedCreationTime` in VSD API.
"""
self._associated_key_server_monitor_seed_creation_time = value
@property
def associated_key_server_monitor_seed_id(self):
""" Get associated_key_server_monitor_seed_id value.
Notes:
The ID of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSeedID` in VSD API.
"""
return self._associated_key_server_monitor_seed_id
@associated_key_server_monitor_seed_id.setter
def associated_key_server_monitor_seed_id(self, value):
""" Set associated_key_server_monitor_seed_id value.
Notes:
The ID of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSeedID` in VSD API.
"""
self._associated_key_server_monitor_seed_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUKeyServerMonitorEncryptedSeed
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_key_server_monitor_seed_creation_time
Get associated_key_server_monitor_seed_creation_time value.
Notes: The creation time of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSeedCreationTime` in VSD API.
var associated_key_server_monitor_seed_id
Get associated_key_server_monitor_seed_id value.
Notes: The ID of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSeedID` in VSD API.
var associated_key_server_monitor_sek_creation_time
Get associated_key_server_monitor_sek_creation_time value.
Notes: The creation time of the associated KeyServer Monitor Seed ID
This attribute is named `associatedKeyServerMonitorSEKCreationTime` in VSD API.
var associated_key_server_monitor_sekid
Get associated_key_server_monitor_sekid value.
Notes: The ID of the associated KeyServer Monitor SEK ID
This attribute is named `associatedKeyServerMonitorSEKID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var enterprise_secured_data_id
Get enterprise_secured_data_id value.
Notes: Enterprise Secured ID record this monitor represents
This attribute is named `enterpriseSecuredDataID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var key_server_certificate_serial_number
Get key_server_certificate_serial_number value.
Notes: KeyServer Certificate Serial Number
This attribute is named `keyServerCertificateSerialNumber` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var sek_creation_time
Get sek_creation_time value.
Notes: SEK Creation Time
This attribute is named `SEKCreationTime` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a KeyServerMonitorEncryptedSeed instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> keyservermonitorencryptedseed = NUKeyServerMonitorEncryptedSeed(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorEncryptedSeed') >>> keyservermonitorencryptedseed = NUKeyServerMonitorEncryptedSeed(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitorEncryptedSeed instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitorencryptedseed = NUKeyServerMonitorEncryptedSeed(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorEncryptedSeed')
>>> keyservermonitorencryptedseed = NUKeyServerMonitorEncryptedSeed(data=my_dict)
"""
super(NUKeyServerMonitorEncryptedSeed, self).__init__()
# Read/Write Attributes
self._sek_creation_time = None
self._last_updated_by = None
self._key_server_certificate_serial_number = None
self._enterprise_secured_data_id = None
self._entity_scope = None
self._associated_key_server_monitor_sek_creation_time = None
self._associated_key_server_monitor_sekid = None
self._associated_key_server_monitor_seed_creation_time = None
self._associated_key_server_monitor_seed_id = None
self._external_id = None
self.expose_attribute(local_name="sek_creation_time", remote_name="SEKCreationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="key_server_certificate_serial_number", remote_name="keyServerCertificateSerialNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_secured_data_id", remote_name="enterpriseSecuredDataID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_key_server_monitor_sek_creation_time", remote_name="associatedKeyServerMonitorSEKCreationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_key_server_monitor_sekid", remote_name="associatedKeyServerMonitorSEKID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_key_server_monitor_seed_creation_time", remote_name="associatedKeyServerMonitorSeedCreationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_key_server_monitor_seed_id", remote_name="associatedKeyServerMonitorSeedID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUKeyServerMonitorSEK
Represents a KeyServerMonitorSEK in the VSD
Notes: Represents a Keyserver Monitor SEK Snapshot
class NUKeyServerMonitorSEK(NURESTObject):
""" Represents a KeyServerMonitorSEK in the VSD
Notes:
Represents a Keyserver Monitor SEK Snapshot
"""
__rest_name__ = "keyservermonitorsek"
__resource_name__ = "keyservermonitorseks"
## Constants
CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA256 = "HMAC_SHA256"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_128_CBC = "AES_128_CBC"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA512 = "HMAC_SHA512"
CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_256_CBC = "AES_256_CBC"
CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC = "TRIPLE_DES_CBC"
CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA1 = "HMAC_SHA1"
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitorSEK instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitorsek = NUKeyServerMonitorSEK(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorSEK')
>>> keyservermonitorsek = NUKeyServerMonitorSEK(data=my_dict)
"""
super(NUKeyServerMonitorSEK, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._seed_payload_authentication_algorithm = None
self._seed_payload_encryption_algorithm = None
self._lifetime = None
self._entity_scope = None
self._creation_time = None
self._start_time = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_authentication_algorithm", remote_name="seedPayloadAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA512'])
self.expose_attribute(local_name="seed_payload_encryption_algorithm", remote_name="seedPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="lifetime", remote_name="lifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="creation_time", remote_name="creationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="start_time", remote_name="startTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_encrypted_seeds = NUKeyServerMonitorEncryptedSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def seed_payload_authentication_algorithm(self):
""" Get seed_payload_authentication_algorithm value.
Notes:
SEK Payload Signature Algorithm Possible values are HMAC_SHA1, HMAC_SHA256, HMAC_SHA512, .
This attribute is named `seedPayloadAuthenticationAlgorithm` in VSD API.
"""
return self._seed_payload_authentication_algorithm
@seed_payload_authentication_algorithm.setter
def seed_payload_authentication_algorithm(self, value):
""" Set seed_payload_authentication_algorithm value.
Notes:
SEK Payload Signature Algorithm Possible values are HMAC_SHA1, HMAC_SHA256, HMAC_SHA512, .
This attribute is named `seedPayloadAuthenticationAlgorithm` in VSD API.
"""
self._seed_payload_authentication_algorithm = value
@property
def seed_payload_encryption_algorithm(self):
""" Get seed_payload_encryption_algorithm value.
Notes:
SEK Payload Encryption Algorithm Possible values are AES_128_CBC, AES_256_CBC, TRIPLE_DES_CBC, .
This attribute is named `seedPayloadEncryptionAlgorithm` in VSD API.
"""
return self._seed_payload_encryption_algorithm
@seed_payload_encryption_algorithm.setter
def seed_payload_encryption_algorithm(self, value):
""" Set seed_payload_encryption_algorithm value.
Notes:
SEK Payload Encryption Algorithm Possible values are AES_128_CBC, AES_256_CBC, TRIPLE_DES_CBC, .
This attribute is named `seedPayloadEncryptionAlgorithm` in VSD API.
"""
self._seed_payload_encryption_algorithm = value
@property
def lifetime(self):
""" Get lifetime value.
Notes:
The lifetime of this entry (seconds)
"""
return self._lifetime
@lifetime.setter
def lifetime(self, value):
""" Set lifetime value.
Notes:
The lifetime of this entry (seconds)
"""
self._lifetime = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def creation_time(self):
""" Get creation_time value.
Notes:
The time this entry was created (milliseconds since epoch)
This attribute is named `creationTime` in VSD API.
"""
return self._creation_time
@creation_time.setter
def creation_time(self, value):
""" Set creation_time value.
Notes:
The time this entry was created (milliseconds since epoch)
This attribute is named `creationTime` in VSD API.
"""
self._creation_time = value
@property
def start_time(self):
""" Get start_time value.
Notes:
The time this entry was activated (milliseconds since epoch)
This attribute is named `startTime` in VSD API.
"""
return self._start_time
@start_time.setter
def start_time(self, value):
""" Set start_time value.
Notes:
The time this entry was activated (milliseconds since epoch)
This attribute is named `startTime` in VSD API.
"""
self._start_time = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUKeyServerMonitorSEK
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA1
var CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA256
var CONST_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA512
var CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_128_CBC
var CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_256_CBC
var CONST_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var creation_time
Get creation_time value.
Notes: The time this entry was created (milliseconds since epoch)
This attribute is named `creationTime` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var key_server_monitor_encrypted_seeds
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var lifetime
Get lifetime value.
Notes: The lifetime of this entry (seconds)
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var seed_payload_authentication_algorithm
Get seed_payload_authentication_algorithm value.
Notes: SEK Payload Signature Algorithm Possible values are HMAC_SHA1, HMAC_SHA256, HMAC_SHA512, .
This attribute is named `seedPayloadAuthenticationAlgorithm` in VSD API.
var seed_payload_encryption_algorithm
Get seed_payload_encryption_algorithm value.
Notes: SEK Payload Encryption Algorithm Possible values are AES_128_CBC, AES_256_CBC, TRIPLE_DES_CBC, .
This attribute is named `seedPayloadEncryptionAlgorithm` in VSD API.
var start_time
Get start_time value.
Notes: The time this entry was activated (milliseconds since epoch)
This attribute is named `startTime` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a KeyServerMonitorSEK instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> keyservermonitorsek = NUKeyServerMonitorSEK(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorSEK') >>> keyservermonitorsek = NUKeyServerMonitorSEK(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitorSEK instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitorsek = NUKeyServerMonitorSEK(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorSEK')
>>> keyservermonitorsek = NUKeyServerMonitorSEK(data=my_dict)
"""
super(NUKeyServerMonitorSEK, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._seed_payload_authentication_algorithm = None
self._seed_payload_encryption_algorithm = None
self._lifetime = None
self._entity_scope = None
self._creation_time = None
self._start_time = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_payload_authentication_algorithm", remote_name="seedPayloadAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA512'])
self.expose_attribute(local_name="seed_payload_encryption_algorithm", remote_name="seedPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="lifetime", remote_name="lifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="creation_time", remote_name="creationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="start_time", remote_name="startTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_encrypted_seeds = NUKeyServerMonitorEncryptedSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUKeyServerMonitorSeed
Represents a KeyServerMonitorSeed in the VSD
Notes: Represents a Keyserver Monitor Seed Snapshot.
class NUKeyServerMonitorSeed(NURESTObject):
""" Represents a KeyServerMonitorSeed in the VSD
Notes:
Represents a Keyserver Monitor Seed Snapshot.
"""
__rest_name__ = "keyservermonitorseed"
__resource_name__ = "keyservermonitorseeds"
## Constants
CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC = "TRIPLE_DES_CBC"
CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA512 = "HMAC_SHA512"
CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA1 = "HMAC_SHA1"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA384 = "HMAC_SHA384"
CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_AES_256_CBC = "AES_256_CBC"
CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_AES_128_CBC = "AES_128_CBC"
CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_AES_192_CBC = "AES_192_CBC"
CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_MD5 = "HMAC_MD5"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA256 = "HMAC_SHA256"
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitorSeed instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitorseed = NUKeyServerMonitorSeed(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorSeed')
>>> keyservermonitorseed = NUKeyServerMonitorSeed(data=my_dict)
"""
super(NUKeyServerMonitorSeed, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._seed_traffic_authentication_algorithm = None
self._seed_traffic_encryption_algorithm = None
self._seed_traffic_encryption_key_lifetime = None
self._lifetime = None
self._entity_scope = None
self._creation_time = None
self._start_time = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_traffic_authentication_algorithm", remote_name="seedTrafficAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_MD5', u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA384', u'HMAC_SHA512'])
self.expose_attribute(local_name="seed_traffic_encryption_algorithm", remote_name="seedTrafficEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_192_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="seed_traffic_encryption_key_lifetime", remote_name="seedTrafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="lifetime", remote_name="lifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="creation_time", remote_name="creationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="start_time", remote_name="startTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_encrypted_seeds = NUKeyServerMonitorEncryptedSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def seed_traffic_authentication_algorithm(self):
""" Get seed_traffic_authentication_algorithm value.
Notes:
Seed traffic Authentication Algorithm.
This attribute is named `seedTrafficAuthenticationAlgorithm` in VSD API.
"""
return self._seed_traffic_authentication_algorithm
@seed_traffic_authentication_algorithm.setter
def seed_traffic_authentication_algorithm(self, value):
""" Set seed_traffic_authentication_algorithm value.
Notes:
Seed traffic Authentication Algorithm.
This attribute is named `seedTrafficAuthenticationAlgorithm` in VSD API.
"""
self._seed_traffic_authentication_algorithm = value
@property
def seed_traffic_encryption_algorithm(self):
""" Get seed_traffic_encryption_algorithm value.
Notes:
Seed traffic Encryption Algorithm.
This attribute is named `seedTrafficEncryptionAlgorithm` in VSD API.
"""
return self._seed_traffic_encryption_algorithm
@seed_traffic_encryption_algorithm.setter
def seed_traffic_encryption_algorithm(self, value):
""" Set seed_traffic_encryption_algorithm value.
Notes:
Seed traffic Encryption Algorithm.
This attribute is named `seedTrafficEncryptionAlgorithm` in VSD API.
"""
self._seed_traffic_encryption_algorithm = value
@property
def seed_traffic_encryption_key_lifetime(self):
""" Get seed_traffic_encryption_key_lifetime value.
Notes:
Seed Traffic Encryption Key Lifetime in Seconds
This attribute is named `seedTrafficEncryptionKeyLifetime` in VSD API.
"""
return self._seed_traffic_encryption_key_lifetime
@seed_traffic_encryption_key_lifetime.setter
def seed_traffic_encryption_key_lifetime(self, value):
""" Set seed_traffic_encryption_key_lifetime value.
Notes:
Seed Traffic Encryption Key Lifetime in Seconds
This attribute is named `seedTrafficEncryptionKeyLifetime` in VSD API.
"""
self._seed_traffic_encryption_key_lifetime = value
@property
def lifetime(self):
""" Get lifetime value.
Notes:
The lifetime of this entry (seconds)
"""
return self._lifetime
@lifetime.setter
def lifetime(self, value):
""" Set lifetime value.
Notes:
The lifetime of this entry (seconds)
"""
self._lifetime = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def creation_time(self):
""" Get creation_time value.
Notes:
The time this entry was created (milliseconds since epoch)
This attribute is named `creationTime` in VSD API.
"""
return self._creation_time
@creation_time.setter
def creation_time(self, value):
""" Set creation_time value.
Notes:
The time this entry was created (milliseconds since epoch)
This attribute is named `creationTime` in VSD API.
"""
self._creation_time = value
@property
def start_time(self):
""" Get start_time value.
Notes:
The time this entry was activated (milliseconds since epoch)
This attribute is named `startTime` in VSD API.
"""
return self._start_time
@start_time.setter
def start_time(self, value):
""" Set start_time value.
Notes:
The time this entry was activated (milliseconds since epoch)
This attribute is named `startTime` in VSD API.
"""
self._start_time = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUKeyServerMonitorSeed
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_MD5
var CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA1
var CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA256
var CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA384
var CONST_SEED_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA512
var CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_AES_128_CBC
var CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_AES_192_CBC
var CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_AES_256_CBC
var CONST_SEED_TRAFFIC_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var creation_time
Get creation_time value.
Notes: The time this entry was created (milliseconds since epoch)
This attribute is named `creationTime` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var key_server_monitor_encrypted_seeds
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var lifetime
Get lifetime value.
Notes: The lifetime of this entry (seconds)
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var seed_traffic_authentication_algorithm
Get seed_traffic_authentication_algorithm value.
Notes: Seed traffic Authentication Algorithm.
This attribute is named `seedTrafficAuthenticationAlgorithm` in VSD API.
var seed_traffic_encryption_algorithm
Get seed_traffic_encryption_algorithm value.
Notes: Seed traffic Encryption Algorithm.
This attribute is named `seedTrafficEncryptionAlgorithm` in VSD API.
var seed_traffic_encryption_key_lifetime
Get seed_traffic_encryption_key_lifetime value.
Notes: Seed Traffic Encryption Key Lifetime in Seconds
This attribute is named `seedTrafficEncryptionKeyLifetime` in VSD API.
var start_time
Get start_time value.
Notes: The time this entry was activated (milliseconds since epoch)
This attribute is named `startTime` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a KeyServerMonitorSeed instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> keyservermonitorseed = NUKeyServerMonitorSeed(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorSeed') >>> keyservermonitorseed = NUKeyServerMonitorSeed(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a KeyServerMonitorSeed instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> keyservermonitorseed = NUKeyServerMonitorSeed(id=u'xxxx-xxx-xxx-xxx', name=u'KeyServerMonitorSeed')
>>> keyservermonitorseed = NUKeyServerMonitorSeed(data=my_dict)
"""
super(NUKeyServerMonitorSeed, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._seed_traffic_authentication_algorithm = None
self._seed_traffic_encryption_algorithm = None
self._seed_traffic_encryption_key_lifetime = None
self._lifetime = None
self._entity_scope = None
self._creation_time = None
self._start_time = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="seed_traffic_authentication_algorithm", remote_name="seedTrafficAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_MD5', u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA384', u'HMAC_SHA512'])
self.expose_attribute(local_name="seed_traffic_encryption_algorithm", remote_name="seedTrafficEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_192_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="seed_traffic_encryption_key_lifetime", remote_name="seedTrafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="lifetime", remote_name="lifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="creation_time", remote_name="creationTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="start_time", remote_name="startTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.key_server_monitor_encrypted_seeds = NUKeyServerMonitorEncryptedSeedsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUL2Domain
Represents a L2Domain in the VSD
Notes: This is the definition of a l2 domain associated with a Enterprise.
class NUL2Domain(NURESTObject):
""" Represents a L2Domain in the VSD
Notes:
This is the definition of a l2 domain associated with a Enterprise.
"""
__rest_name__ = "l2domain"
__resource_name__ = "l2domains"
## Constants
CONST_MAINTENANCE_MODE_ENABLED_INHERITED = "ENABLED_INHERITED"
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_MAINTENANCE_MODE_ENABLED = "ENABLED"
CONST_POLICY_CHANGE_STATUS_STARTED = "STARTED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_UPLINK_PREFERENCE_SECONDARY_PRIMARY = "SECONDARY_PRIMARY"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_UPLINK_PREFERENCE_PRIMARY_SECONDARY = "PRIMARY_SECONDARY"
CONST_POLICY_CHANGE_STATUS_DISCARDED = "DISCARDED"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_MULTICAST_INHERITED = "INHERITED"
CONST_MAINTENANCE_MODE_DISABLED = "DISABLED"
CONST_UPLINK_PREFERENCE_SYMMETRIC = "SYMMETRIC"
CONST_POLICY_CHANGE_STATUS_APPLIED = "APPLIED"
CONST_UPLINK_PREFERENCE_SECONDARY = "SECONDARY"
CONST_UPLINK_PREFERENCE_PRIMARY = "PRIMARY"
def __init__(self, **kwargs):
""" Initializes a L2Domain instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> l2domain = NUL2Domain(id=u'xxxx-xxx-xxx-xxx', name=u'L2Domain')
>>> l2domain = NUL2Domain(data=my_dict)
"""
super(NUL2Domain, self).__init__()
# Read/Write Attributes
self._dhcp_managed = None
self._ip_type = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._gateway_mac_address = None
self._address = None
self._template_id = None
self._service_id = None
self._description = None
self._netmask = None
self._vn_id = None
self._encryption = None
self._entity_scope = None
self._policy_change_status = None
self._route_distinguisher = None
self._route_target = None
self._uplink_preference = None
self._associated_multicast_channel_map_id = None
self._associated_shared_network_resource_id = None
self._stretched = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="dhcp_managed", remote_name="DHCPManaged", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_mac_address", remote_name="gatewayMACAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id", remote_name="serviceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vn_id", remote_name="vnId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_target", remote_name="routeTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uplink_preference", remote_name="uplinkPreference", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'PRIMARY_SECONDARY', u'SECONDARY', u'SECONDARY_PRIMARY', u'SYMMETRIC'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_shared_network_resource_id", remote_name="associatedSharedNetworkResourceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stretched", remote_name="stretched", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.uplink_rds = NUUplinkRDsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vpn_connections = NUVPNConnectionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bridge_interfaces = NUBridgeInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dhcp_managed(self):
""" Get dhcp_managed value.
Notes:
decides whether L2Domain / L2Domain template DHCP is managed by VSD
This attribute is named `DHCPManaged` in VSD API.
"""
return self._dhcp_managed
@dhcp_managed.setter
def dhcp_managed(self, value):
""" Set dhcp_managed value.
Notes:
decides whether L2Domain / L2Domain template DHCP is managed by VSD
This attribute is named `DHCPManaged` in VSD API.
"""
self._dhcp_managed = value
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def maintenance_mode(self):
""" Get maintenance_mode value.
Notes:
maintenanceMode is an enum that indicates if the L2Domain is accepting VM activation requests. Possible values are DISABLED, ENABLED and ENABLED_INHERITED Possible values are .
This attribute is named `maintenanceMode` in VSD API.
"""
return self._maintenance_mode
@maintenance_mode.setter
def maintenance_mode(self, value):
""" Set maintenance_mode value.
Notes:
maintenanceMode is an enum that indicates if the L2Domain is accepting VM activation requests. Possible values are DISABLED, ENABLED and ENABLED_INHERITED Possible values are .
This attribute is named `maintenanceMode` in VSD API.
"""
self._maintenance_mode = value
@property
def name(self):
""" Get name value.
Notes:
Name of the L2Domain / L2Domain template,has to be unique within a Enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the L2Domain / L2Domain template,has to be unique within a Enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
The IP address of the gateway of this l2 domain
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
The IP address of the gateway of this l2 domain
"""
self._gateway = value
@property
def gateway_mac_address(self):
""" Get gateway_mac_address value.
Notes:
The MAC address of the Gateway.
This attribute is named `gatewayMACAddress` in VSD API.
"""
return self._gateway_mac_address
@gateway_mac_address.setter
def gateway_mac_address(self, value):
""" Set gateway_mac_address value.
Notes:
The MAC address of the Gateway.
This attribute is named `gatewayMACAddress` in VSD API.
"""
self._gateway_mac_address = value
@property
def address(self):
""" Get address value.
Notes:
Network address of the L2Domain / L2Domain template defined.
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
Network address of the L2Domain / L2Domain template defined.
"""
self._address = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the L2 Domain template that this L2 Domain object was derived from
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the L2 Domain template that this L2 Domain object was derived from
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def service_id(self):
""" Get service_id value.
Notes:
The service ID used by the VSCs to identify this subnet
This attribute is named `serviceID` in VSD API.
"""
return self._service_id
@service_id.setter
def service_id(self, value):
""" Set service_id value.
Notes:
The service ID used by the VSCs to identify this subnet
This attribute is named `serviceID` in VSD API.
"""
self._service_id = value
@property
def description(self):
""" Get description value.
Notes:
A description field provided by the user that identifies the L2Domain / L2Domain template.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description field provided by the user that identifies the L2Domain / L2Domain template.
"""
self._description = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the L2Domain / L2Domain template defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the L2Domain / L2Domain template defined
"""
self._netmask = value
@property
def vn_id(self):
""" Get vn_id value.
Notes:
Current Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `vnId` in VSD API.
"""
return self._vn_id
@vn_id.setter
def vn_id(self, value):
""" Set vn_id value.
Notes:
Current Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `vnId` in VSD API.
"""
self._vn_id = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
"""
self._encryption = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_change_status(self):
""" Get policy_change_status value.
Notes:
None
This attribute is named `policyChangeStatus` in VSD API.
"""
return self._policy_change_status
@policy_change_status.setter
def policy_change_status(self, value):
""" Set policy_change_status value.
Notes:
None
This attribute is named `policyChangeStatus` in VSD API.
"""
self._policy_change_status = value
@property
def route_distinguisher(self):
""" Get route_distinguisher value.
Notes:
The Route Distinguisher value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeDistinguisher` in VSD API.
"""
return self._route_distinguisher
@route_distinguisher.setter
def route_distinguisher(self, value):
""" Set route_distinguisher value.
Notes:
The Route Distinguisher value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeDistinguisher` in VSD API.
"""
self._route_distinguisher = value
@property
def route_target(self):
""" Get route_target value.
Notes:
The Route Target value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeTarget` in VSD API.
"""
return self._route_target
@route_target.setter
def route_target(self, value):
""" Set route_target value.
Notes:
The Route Target value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeTarget` in VSD API.
"""
self._route_target = value
@property
def uplink_preference(self):
""" Get uplink_preference value.
Notes:
Indicates the preferencial path selection for network traffic in this domain - Default is Primary 1 and Secondary 2. Possible values are PRIMARY_SECONDARY, SECONDARY_PRIMARY, PRIMARY, SECONDARY, SYMMETRIC, .
This attribute is named `uplinkPreference` in VSD API.
"""
return self._uplink_preference
@uplink_preference.setter
def uplink_preference(self, value):
""" Set uplink_preference value.
Notes:
Indicates the preferencial path selection for network traffic in this domain - Default is Primary 1 and Secondary 2. Possible values are PRIMARY_SECONDARY, SECONDARY_PRIMARY, PRIMARY, SECONDARY, SYMMETRIC, .
This attribute is named `uplinkPreference` in VSD API.
"""
self._uplink_preference = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this L2Domain / L2Domain template template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this L2Domain / L2Domain template template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def associated_shared_network_resource_id(self):
""" Get associated_shared_network_resource_id value.
Notes:
The ID of the L2 Domain that this L2 Domain object is pointing to
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
"""
return self._associated_shared_network_resource_id
@associated_shared_network_resource_id.setter
def associated_shared_network_resource_id(self, value):
""" Set associated_shared_network_resource_id value.
Notes:
The ID of the L2 Domain that this L2 Domain object is pointing to
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
"""
self._associated_shared_network_resource_id = value
@property
def stretched(self):
""" Get stretched value.
Notes:
Indicates whether this domain is streched,if so remote VM resolutions will be allowed
"""
return self._stretched
@stretched.setter
def stretched(self, value):
""" Set stretched value.
Notes:
Indicates whether this domain is streched,if so remote VM resolutions will be allowed
"""
self._stretched = value
@property
def multicast(self):
""" Get multicast value.
Notes:
Indicates multicast policy on L2Domain.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
Indicates multicast policy on L2Domain.
"""
self._multicast = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUL2Domain
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var CONST_MAINTENANCE_MODE_DISABLED
var CONST_MAINTENANCE_MODE_ENABLED
var CONST_MAINTENANCE_MODE_ENABLED_INHERITED
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var CONST_POLICY_CHANGE_STATUS_APPLIED
var CONST_POLICY_CHANGE_STATUS_DISCARDED
var CONST_POLICY_CHANGE_STATUS_STARTED
var CONST_UPLINK_PREFERENCE_PRIMARY
var CONST_UPLINK_PREFERENCE_PRIMARY_SECONDARY
var CONST_UPLINK_PREFERENCE_SECONDARY
var CONST_UPLINK_PREFERENCE_SECONDARY_PRIMARY
var CONST_UPLINK_PREFERENCE_SYMMETRIC
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: Network address of the L2Domain / L2Domain template defined.
var address_ranges
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this L2Domain / L2Domain template template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
Get associated_shared_network_resource_id value.
Notes: The ID of the L2 Domain that this L2 Domain object is pointing to
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
var bridge_interfaces
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description field provided by the user that identifies the L2Domain / L2Domain template.
var dhcp_managed
Get dhcp_managed value.
Notes: decides whether L2Domain / L2Domain template DHCP is managed by VSD
This attribute is named `DHCPManaged` in VSD API.
var dhcp_options
var egress_acl_entry_templates
var egress_acl_templates
var encryption
Get encryption value.
Notes: Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: The IP address of the gateway of this l2 domain
var gateway_mac_address
Get gateway_mac_address value.
Notes: The MAC address of the Gateway.
This attribute is named `gatewayMACAddress` in VSD API.
var global_metadatas
var groups
var host_interfaces
var id
Get object id
var ingress_acl_entry_templates
var ingress_acl_templates
var ingress_adv_fwd_templates
var ingress_external_service_templates
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6
This attribute is named `IPType` in VSD API.
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var maintenance_mode
Get maintenance_mode value.
Notes: maintenanceMode is an enum that indicates if the L2Domain is accepting VM activation requests. Possible values are DISABLED, ENABLED and ENABLED_INHERITED Possible values are .
This attribute is named `maintenanceMode` in VSD API.
var metadatas
var multicast
Get multicast value.
Notes: Indicates multicast policy on L2Domain.
var name
Get name value.
Notes: Name of the L2Domain / L2Domain template,has to be unique within a Enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the L2Domain / L2Domain template defined
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var policy_change_status
Get policy_change_status value.
Notes: None
This attribute is named `policyChangeStatus` in VSD API.
var policy_groups
var qoss
var redirection_targets
var route_distinguisher
Get route_distinguisher value.
Notes: The Route Distinguisher value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeDistinguisher` in VSD API.
var route_target
Get route_target value.
Notes: The Route Target value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeTarget` in VSD API.
var service_id
Get service_id value.
Notes: The service ID used by the VSCs to identify this subnet
This attribute is named `serviceID` in VSD API.
var static_routes
var statistics
var statistics_policies
var stretched
Get stretched value.
Notes: Indicates whether this domain is streched,if so remote VM resolutions will be allowed
var tcas
var template_id
Get template_id value.
Notes: The ID of the L2 Domain template that this L2 Domain object was derived from
This attribute is named `templateID` in VSD API.
var uplink_preference
Get uplink_preference value.
Notes: Indicates the preferencial path selection for network traffic in this domain - Default is Primary 1 and Secondary 2. Possible values are PRIMARY_SECONDARY, SECONDARY_PRIMARY, PRIMARY, SECONDARY, SYMMETRIC, .
This attribute is named `uplinkPreference` in VSD API.
var uplink_rds
var vm_interfaces
var vms
var vn_id
Get vn_id value.
Notes: Current Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `vnId` in VSD API.
var vpn_connections
var vports
Methods
def __init__(
self, **kwargs)
Initializes a L2Domain instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> l2domain = NUL2Domain(id=u'xxxx-xxx-xxx-xxx', name=u'L2Domain') >>> l2domain = NUL2Domain(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a L2Domain instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> l2domain = NUL2Domain(id=u'xxxx-xxx-xxx-xxx', name=u'L2Domain')
>>> l2domain = NUL2Domain(data=my_dict)
"""
super(NUL2Domain, self).__init__()
# Read/Write Attributes
self._dhcp_managed = None
self._ip_type = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._gateway_mac_address = None
self._address = None
self._template_id = None
self._service_id = None
self._description = None
self._netmask = None
self._vn_id = None
self._encryption = None
self._entity_scope = None
self._policy_change_status = None
self._route_distinguisher = None
self._route_target = None
self._uplink_preference = None
self._associated_multicast_channel_map_id = None
self._associated_shared_network_resource_id = None
self._stretched = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="dhcp_managed", remote_name="DHCPManaged", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_mac_address", remote_name="gatewayMACAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id", remote_name="serviceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vn_id", remote_name="vnId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_target", remote_name="routeTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uplink_preference", remote_name="uplinkPreference", attribute_type=str, is_required=False, is_unique=False, choices=[u'PRIMARY', u'PRIMARY_SECONDARY', u'SECONDARY', u'SECONDARY_PRIMARY', u'SYMMETRIC'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_shared_network_resource_id", remote_name="associatedSharedNetworkResourceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stretched", remote_name="stretched", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.uplink_rds = NUUplinkRDsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vpn_connections = NUVPNConnectionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bridge_interfaces = NUBridgeInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUL2DomainTemplate
Represents a L2DomainTemplate in the VSD
Notes: L2 Domain in VSD as derived by templates. This object describes the L2 Domain template.
class NUL2DomainTemplate(NURESTObject):
""" Represents a L2DomainTemplate in the VSD
Notes:
L2 Domain in VSD as derived by templates. This object describes the L2 Domain template.
"""
__rest_name__ = "l2domaintemplate"
__resource_name__ = "l2domaintemplates"
## Constants
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_POLICY_CHANGE_STATUS_STARTED = "STARTED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_POLICY_CHANGE_STATUS_DISCARDED = "DISCARDED"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_MULTICAST_INHERITED = "INHERITED"
CONST_POLICY_CHANGE_STATUS_APPLIED = "APPLIED"
def __init__(self, **kwargs):
""" Initializes a L2DomainTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> l2domaintemplate = NUL2DomainTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'L2DomainTemplate')
>>> l2domaintemplate = NUL2DomainTemplate(data=my_dict)
"""
super(NUL2DomainTemplate, self).__init__()
# Read/Write Attributes
self._dhcp_managed = None
self._ip_type = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._policy_change_status = None
self._associated_multicast_channel_map_id = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="dhcp_managed", remote_name="DHCPManaged", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.l2_domains = NUL2DomainsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_target_templates = NURedirectionTargetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_group_templates = NUPolicyGroupTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dhcp_managed(self):
""" Get dhcp_managed value.
Notes:
decides whether L2Domain / L2Domain template DHCP is managed by VSD
This attribute is named `DHCPManaged` in VSD API.
"""
return self._dhcp_managed
@dhcp_managed.setter
def dhcp_managed(self, value):
""" Set dhcp_managed value.
Notes:
decides whether L2Domain / L2Domain template DHCP is managed by VSD
This attribute is named `DHCPManaged` in VSD API.
"""
self._dhcp_managed = value
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def name(self):
""" Get name value.
Notes:
Name of the L2Domain / L2Domain template,has to be unique within a Enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the L2Domain / L2Domain template,has to be unique within a Enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
The IP address of the gateway of this l2 domain
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
The IP address of the gateway of this l2 domain
"""
self._gateway = value
@property
def address(self):
""" Get address value.
Notes:
Network address of the L2Domain / L2Domain template defined.
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
Network address of the L2Domain / L2Domain template defined.
"""
self._address = value
@property
def description(self):
""" Get description value.
Notes:
A description field provided by the user that identifies the L2Domain / L2Domain template.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description field provided by the user that identifies the L2Domain / L2Domain template.
"""
self._description = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the L2Domain / L2Domain template defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the L2Domain / L2Domain template defined
"""
self._netmask = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
"""
self._encryption = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_change_status(self):
""" Get policy_change_status value.
Notes:
This attribute is named `policyChangeStatus` in VSD API.
"""
return self._policy_change_status
@policy_change_status.setter
def policy_change_status(self, value):
""" Set policy_change_status value.
Notes:
This attribute is named `policyChangeStatus` in VSD API.
"""
self._policy_change_status = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this L2Domain / L2Domain template template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this L2Domain / L2Domain template template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def multicast(self):
""" Get multicast value.
Notes:
Indicates multicast policy on L2Domain template.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
Indicates multicast policy on L2Domain template.
"""
self._multicast = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUL2DomainTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var CONST_POLICY_CHANGE_STATUS_APPLIED
var CONST_POLICY_CHANGE_STATUS_DISCARDED
var CONST_POLICY_CHANGE_STATUS_STARTED
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: Network address of the L2Domain / L2Domain template defined.
var address_ranges
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this L2Domain / L2Domain template template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description field provided by the user that identifies the L2Domain / L2Domain template.
var dhcp_managed
Get dhcp_managed value.
Notes: decides whether L2Domain / L2Domain template DHCP is managed by VSD
This attribute is named `DHCPManaged` in VSD API.
var egress_acl_templates
var encryption
Get encryption value.
Notes: Determines whether IPSEC is enabled Possible values are ENABLED, DISABLED, .
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: The IP address of the gateway of this l2 domain
var global_metadatas
var groups
var id
Get object id
var ingress_acl_templates
var ingress_adv_fwd_templates
var ingress_external_service_templates
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6
This attribute is named `IPType` in VSD API.
var jobs
var l2_domains
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var multicast
Get multicast value.
Notes: Indicates multicast policy on L2Domain template.
var name
Get name value.
Notes: Name of the L2Domain / L2Domain template,has to be unique within a Enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the L2Domain / L2Domain template defined
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var policy_change_status
Get policy_change_status value.
Notes:
This attribute is named `policyChangeStatus` in VSD API.
var policy_group_templates
var qoss
var redirection_target_templates
Methods
def __init__(
self, **kwargs)
Initializes a L2DomainTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> l2domaintemplate = NUL2DomainTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'L2DomainTemplate') >>> l2domaintemplate = NUL2DomainTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a L2DomainTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> l2domaintemplate = NUL2DomainTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'L2DomainTemplate')
>>> l2domaintemplate = NUL2DomainTemplate(data=my_dict)
"""
super(NUL2DomainTemplate, self).__init__()
# Read/Write Attributes
self._dhcp_managed = None
self._ip_type = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._policy_change_status = None
self._associated_multicast_channel_map_id = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="dhcp_managed", remote_name="DHCPManaged", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_change_status", remote_name="policyChangeStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'DISCARDED', u'STARTED'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.l2_domains = NUL2DomainsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_target_templates = NURedirectionTargetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_adv_fwd_templates = NUIngressAdvFwdTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ingress_external_service_templates = NUIngressExternalServiceTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_group_templates = NUPolicyGroupTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NULDAPConfiguration
Represents a LDAPConfiguration in the VSD
Notes: Configuration of LDAP parameters associated with an enterprise. This will enable authentication through an external LDAP server for this enterprise.
class NULDAPConfiguration(NURESTObject):
""" Represents a LDAPConfiguration in the VSD
Notes:
Configuration of LDAP parameters associated with an enterprise. This will enable authentication through an external LDAP server for this enterprise.
"""
__rest_name__ = "ldapconfiguration"
__resource_name__ = "ldapconfigurations"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a LDAPConfiguration instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ldapconfiguration = NULDAPConfiguration(id=u'xxxx-xxx-xxx-xxx', name=u'LDAPConfiguration')
>>> ldapconfiguration = NULDAPConfiguration(data=my_dict)
"""
super(NULDAPConfiguration, self).__init__()
# Read/Write Attributes
self._ssl_enabled = None
self._password = None
self._last_updated_by = None
self._accept_all_certificates = None
self._certificate = None
self._server = None
self._enabled = None
self._entity_scope = None
self._port = None
self._group_dn = None
self._user_dn_template = None
self._authorization_enabled = None
self._authorizing_user_dn = None
self._external_id = None
self.expose_attribute(local_name="ssl_enabled", remote_name="SSLEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="accept_all_certificates", remote_name="acceptAllCertificates", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="certificate", remote_name="certificate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="server", remote_name="server", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="enabled", remote_name="enabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port", remote_name="port", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="group_dn", remote_name="groupDN", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="user_dn_template", remote_name="userDNTemplate", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="authorization_enabled", remote_name="authorizationEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="authorizing_user_dn", remote_name="authorizingUserDN", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ssl_enabled(self):
""" Get ssl_enabled value.
Notes:
Enable SSL for communication with the LDAP server
This attribute is named `SSLEnabled` in VSD API.
"""
return self._ssl_enabled
@ssl_enabled.setter
def ssl_enabled(self, value):
""" Set ssl_enabled value.
Notes:
Enable SSL for communication with the LDAP server
This attribute is named `SSLEnabled` in VSD API.
"""
self._ssl_enabled = value
@property
def password(self):
""" Get password value.
Notes:
This attribute is a mandatory field for LDAP authorization. Password that will be used to verify the integrity of groups and users in LDAP server for the enterprise.
"""
return self._password
@password.setter
def password(self, value):
""" Set password value.
Notes:
This attribute is a mandatory field for LDAP authorization. Password that will be used to verify the integrity of groups and users in LDAP server for the enterprise.
"""
self._password = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def accept_all_certificates(self):
""" Get accept_all_certificates value.
Notes:
Accept all certificates from the LDAP server
This attribute is named `acceptAllCertificates` in VSD API.
"""
return self._accept_all_certificates
@accept_all_certificates.setter
def accept_all_certificates(self, value):
""" Set accept_all_certificates value.
Notes:
Accept all certificates from the LDAP server
This attribute is named `acceptAllCertificates` in VSD API.
"""
self._accept_all_certificates = value
@property
def certificate(self):
""" Get certificate value.
Notes:
The certificate to authenticate with the LDAP server
"""
return self._certificate
@certificate.setter
def certificate(self, value):
""" Set certificate value.
Notes:
The certificate to authenticate with the LDAP server
"""
self._certificate = value
@property
def server(self):
""" Get server value.
Notes:
The LDAP server IP or FQDN
"""
return self._server
@server.setter
def server(self, value):
""" Set server value.
Notes:
The LDAP server IP or FQDN
"""
self._server = value
@property
def enabled(self):
""" Get enabled value.
Notes:
To enable LDAP authentication for an enterprise, set this attribute to true. If enabled is set to false, authorizationEnabled attribute is ignored and LDAP is not used for authentication as well as authorization. The relationship between enabled and authorizationEnabled attributes is as follows, enabled = true, authorizationEnabled = false, LDAP is used only for Authentication enabled = true, authorizationEnabled = true, LDAP is used for both authentication and authorization. enabled = false, authorizationEnabled = true, LDAP is not used. enabled = false, authorizationEnabled = false, LDAP is not used.
"""
return self._enabled
@enabled.setter
def enabled(self, value):
""" Set enabled value.
Notes:
To enable LDAP authentication for an enterprise, set this attribute to true. If enabled is set to false, authorizationEnabled attribute is ignored and LDAP is not used for authentication as well as authorization. The relationship between enabled and authorizationEnabled attributes is as follows, enabled = true, authorizationEnabled = false, LDAP is used only for Authentication enabled = true, authorizationEnabled = true, LDAP is used for both authentication and authorization. enabled = false, authorizationEnabled = true, LDAP is not used. enabled = false, authorizationEnabled = false, LDAP is not used.
"""
self._enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port(self):
""" Get port value.
Notes:
Port to be used for the LDAP server
"""
return self._port
@port.setter
def port(self, value):
""" Set port value.
Notes:
Port to be used for the LDAP server
"""
self._port = value
@property
def group_dn(self):
""" Get group_dn value.
Notes:
This attribute is a mandatory field for LDAP authorization. When LDAP is used for authorization for an enterprise, the group DN will be used to get the list of VSD specific groups in LDAP server for the enterprise. For example, OU=VSDGroups,DC=company,DC=com
This attribute is named `groupDN` in VSD API.
"""
return self._group_dn
@group_dn.setter
def group_dn(self, value):
""" Set group_dn value.
Notes:
This attribute is a mandatory field for LDAP authorization. When LDAP is used for authorization for an enterprise, the group DN will be used to get the list of VSD specific groups in LDAP server for the enterprise. For example, OU=VSDGroups,DC=company,DC=com
This attribute is named `groupDN` in VSD API.
"""
self._group_dn = value
@property
def user_dn_template(self):
""" Get user_dn_template value.
Notes:
The DN template to be used for authentication. The template needs to have a string _USERID_ in it. This will be replaced by the userId of the user who makes the REST API call. For example, template UID=_USERID_,OU=company,DC=com will converted to UID=admin,OU=company,DC=com and this will be used as DN for LDAP authentication.
This attribute is named `userDNTemplate` in VSD API.
"""
return self._user_dn_template
@user_dn_template.setter
def user_dn_template(self, value):
""" Set user_dn_template value.
Notes:
The DN template to be used for authentication. The template needs to have a string _USERID_ in it. This will be replaced by the userId of the user who makes the REST API call. For example, template UID=_USERID_,OU=company,DC=com will converted to UID=admin,OU=company,DC=com and this will be used as DN for LDAP authentication.
This attribute is named `userDNTemplate` in VSD API.
"""
self._user_dn_template = value
@property
def authorization_enabled(self):
""" Get authorization_enabled value.
Notes:
To enable LDAP authorization for an enterprise, both authorizationEnabled and enabled attributes must be set to true. If enabled attribute is not set, this attribute is ignored. The relationship between enabled and authorizationEnabled attributes is as follows, enabled = true, authorizationEnabled = false, LDAP is used only for Authentication. enabled = true, authorizationEnabled = true, LDAP is used for both authentication and authorization. enabled = false, authorizationEnabled = true, LDAP is not used. enabled = false, authorizationEnabled = false, LDAP is not used.
This attribute is named `authorizationEnabled` in VSD API.
"""
return self._authorization_enabled
@authorization_enabled.setter
def authorization_enabled(self, value):
""" Set authorization_enabled value.
Notes:
To enable LDAP authorization for an enterprise, both authorizationEnabled and enabled attributes must be set to true. If enabled attribute is not set, this attribute is ignored. The relationship between enabled and authorizationEnabled attributes is as follows, enabled = true, authorizationEnabled = false, LDAP is used only for Authentication. enabled = true, authorizationEnabled = true, LDAP is used for both authentication and authorization. enabled = false, authorizationEnabled = true, LDAP is not used. enabled = false, authorizationEnabled = false, LDAP is not used.
This attribute is named `authorizationEnabled` in VSD API.
"""
self._authorization_enabled = value
@property
def authorizing_user_dn(self):
""" Get authorizing_user_dn value.
Notes:
This attribute is a mandatory field for LDAP authorization. When LDAP is used for authorization for an enterprise, the user DN that will be used to verify the integrity of groups and users in LDAP server for the enterprise. For example, CN=groupAdmin,OU=VSD_USERS,OU=Personal,OU=Domain Users,DC=company,DC=com
This attribute is named `authorizingUserDN` in VSD API.
"""
return self._authorizing_user_dn
@authorizing_user_dn.setter
def authorizing_user_dn(self, value):
""" Set authorizing_user_dn value.
Notes:
This attribute is a mandatory field for LDAP authorization. When LDAP is used for authorization for an enterprise, the user DN that will be used to verify the integrity of groups and users in LDAP server for the enterprise. For example, CN=groupAdmin,OU=VSD_USERS,OU=Personal,OU=Domain Users,DC=company,DC=com
This attribute is named `authorizingUserDN` in VSD API.
"""
self._authorizing_user_dn = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NULDAPConfiguration
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var accept_all_certificates
Get accept_all_certificates value.
Notes: Accept all certificates from the LDAP server
This attribute is named `acceptAllCertificates` in VSD API.
Get authorization_enabled value.
Notes: To enable LDAP authorization for an enterprise, both authorizationEnabled and enabled attributes must be set to true. If enabled attribute is not set, this attribute is ignored. The relationship between enabled and authorizationEnabled attributes is as follows, enabled = true, authorizationEnabled = false, LDAP is used only for Authentication. enabled = true, authorizationEnabled = true, LDAP is used for both authentication and authorization. enabled = false, authorizationEnabled = true, LDAP is not used. enabled = false, authorizationEnabled = false, LDAP is not used.
This attribute is named `authorizationEnabled` in VSD API.
Get authorizing_user_dn value.
Notes: This attribute is a mandatory field for LDAP authorization. When LDAP is used for authorization for an enterprise, the user DN that will be used to verify the integrity of groups and users in LDAP server for the enterprise. For example, CN=groupAdmin,OU=VSD_USERS,OU=Personal,OU=Domain Users,DC=company,DC=com
This attribute is named `authorizingUserDN` in VSD API.
var certificate
Get certificate value.
Notes: The certificate to authenticate with the LDAP server
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var enabled
Get enabled value.
Notes: To enable LDAP authentication for an enterprise, set this attribute to true. If enabled is set to false, authorizationEnabled attribute is ignored and LDAP is not used for authentication as well as authorization. The relationship between enabled and authorizationEnabled attributes is as follows, enabled = true, authorizationEnabled = false, LDAP is used only for Authentication enabled = true, authorizationEnabled = true, LDAP is used for both authentication and authorization. enabled = false, authorizationEnabled = true, LDAP is not used. enabled = false, authorizationEnabled = false, LDAP is not used.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var group_dn
Get group_dn value.
Notes: This attribute is a mandatory field for LDAP authorization. When LDAP is used for authorization for an enterprise, the group DN will be used to get the list of VSD specific groups in LDAP server for the enterprise. For example, OU=VSDGroups,DC=company,DC=com
This attribute is named `groupDN` in VSD API.
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var password
Get password value.
Notes: This attribute is a mandatory field for LDAP authorization. Password that will be used to verify the integrity of groups and users in LDAP server for the enterprise.
var port
Get port value.
Notes: Port to be used for the LDAP server
var server
Get server value.
Notes: The LDAP server IP or FQDN
var ssl_enabled
Get ssl_enabled value.
Notes: Enable SSL for communication with the LDAP server
This attribute is named `SSLEnabled` in VSD API.
var user_dn_template
Get user_dn_template value.
Notes: The DN template to be used for authentication. The template needs to have a string USERID in it. This will be replaced by the userId of the user who makes the REST API call. For example, template UID=USERID,OU=company,DC=com will converted to UID=admin,OU=company,DC=com and this will be used as DN for LDAP authentication.
This attribute is named `userDNTemplate` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a LDAPConfiguration instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ldapconfiguration = NULDAPConfiguration(id=u'xxxx-xxx-xxx-xxx', name=u'LDAPConfiguration') >>> ldapconfiguration = NULDAPConfiguration(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a LDAPConfiguration instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ldapconfiguration = NULDAPConfiguration(id=u'xxxx-xxx-xxx-xxx', name=u'LDAPConfiguration')
>>> ldapconfiguration = NULDAPConfiguration(data=my_dict)
"""
super(NULDAPConfiguration, self).__init__()
# Read/Write Attributes
self._ssl_enabled = None
self._password = None
self._last_updated_by = None
self._accept_all_certificates = None
self._certificate = None
self._server = None
self._enabled = None
self._entity_scope = None
self._port = None
self._group_dn = None
self._user_dn_template = None
self._authorization_enabled = None
self._authorizing_user_dn = None
self._external_id = None
self.expose_attribute(local_name="ssl_enabled", remote_name="SSLEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="accept_all_certificates", remote_name="acceptAllCertificates", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="certificate", remote_name="certificate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="server", remote_name="server", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="enabled", remote_name="enabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port", remote_name="port", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="group_dn", remote_name="groupDN", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="user_dn_template", remote_name="userDNTemplate", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="authorization_enabled", remote_name="authorizationEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="authorizing_user_dn", remote_name="authorizingUserDN", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NULicense
Represents a License in the VSD
Notes: Enables retrieval/modification and creation of license files. Most of the attributes are retrieved from the encrypted license. The create API simply provides the encrypted license that is in base64 format.
class NULicense(NURESTObject):
""" Represents a License in the VSD
Notes:
Enables retrieval/modification and creation of license files. Most of the attributes are retrieved from the encrypted license. The create API simply provides the encrypted license that is in base64 format.
"""
__rest_name__ = "license"
__resource_name__ = "licenses"
## Constants
CONST_LICENSE_ENCRYPTION_ENCRYPTION_ENABLED = "ENCRYPTION_ENABLED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_LICENSE_TYPE_CLUSTERED = "CLUSTERED"
CONST_LICENSE_TYPE_STANDARD = "STANDARD"
CONST_LICENSE_ENCRYPTION_ENCRYPTION_DISABLED = "ENCRYPTION_DISABLED"
def __init__(self, **kwargs):
""" Initializes a License instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> license = NULicense(id=u'xxxx-xxx-xxx-xxx', name=u'License')
>>> license = NULicense(data=my_dict)
"""
super(NULicense, self).__init__()
# Read/Write Attributes
self._major_release = None
self._last_updated_by = None
self._phone = None
self._license = None
self._license_encryption = None
self._license_id = None
self._license_type = None
self._minor_release = None
self._zip = None
self._city = None
self._allowed_cpes_count = None
self._allowed_nics_count = None
self._allowed_vms_count = None
self._allowed_vrsgs_count = None
self._allowed_vrss_count = None
self._email = None
self._encryption_mode = None
self._entity_scope = None
self._company = None
self._country = None
self._product_version = None
self._provider = None
self._is_cluster_license = None
self._user_name = None
self._state = None
self._street = None
self._customer_key = None
self._expiration_date = None
self._external_id = None
self.expose_attribute(local_name="major_release", remote_name="majorRelease", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="phone", remote_name="phone", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="license", remote_name="license", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="license_encryption", remote_name="licenseEncryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENCRYPTION_DISABLED', u'ENCRYPTION_ENABLED'])
self.expose_attribute(local_name="license_id", remote_name="licenseID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="license_type", remote_name="licenseType", attribute_type=str, is_required=False, is_unique=False, choices=[u'CLUSTERED', u'STANDARD'])
self.expose_attribute(local_name="minor_release", remote_name="minorRelease", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="zip", remote_name="zip", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="city", remote_name="city", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_cpes_count", remote_name="allowedCPEsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_nics_count", remote_name="allowedNICsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_vms_count", remote_name="allowedVMsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_vrsgs_count", remote_name="allowedVRSGsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_vrss_count", remote_name="allowedVRSsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="email", remote_name="email", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption_mode", remote_name="encryptionMode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="company", remote_name="company", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="country", remote_name="country", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="provider", remote_name="provider", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="is_cluster_license", remote_name="isClusterLicense", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="state", remote_name="state", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="street", remote_name="street", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customer_key", remote_name="customerKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="expiration_date", remote_name="expirationDate", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def major_release(self):
""" Get major_release value.
Notes:
Major software release associated with this license
This attribute is named `majorRelease` in VSD API.
"""
return self._major_release
@major_release.setter
def major_release(self, value):
""" Set major_release value.
Notes:
Major software release associated with this license
This attribute is named `majorRelease` in VSD API.
"""
self._major_release = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def phone(self):
""" Get phone value.
Notes:
Phone number of the owner associated with the license file
"""
return self._phone
@phone.setter
def phone(self, value):
""" Set phone value.
Notes:
Phone number of the owner associated with the license file
"""
self._phone = value
@property
def license(self):
""" Get license value.
Notes:
Base 64 value of the license
"""
return self._license
@license.setter
def license(self, value):
""" Set license value.
Notes:
Base 64 value of the license
"""
self._license = value
@property
def license_encryption(self):
""" Get license_encryption value.
Notes:
License encryption
This attribute is named `licenseEncryption` in VSD API.
"""
return self._license_encryption
@license_encryption.setter
def license_encryption(self, value):
""" Set license_encryption value.
Notes:
License encryption
This attribute is named `licenseEncryption` in VSD API.
"""
self._license_encryption = value
@property
def license_id(self):
""" Get license_id value.
Notes:
Unique identifier of the license file
This attribute is named `licenseID` in VSD API.
"""
return self._license_id
@license_id.setter
def license_id(self, value):
""" Set license_id value.
Notes:
Unique identifier of the license file
This attribute is named `licenseID` in VSD API.
"""
self._license_id = value
@property
def license_type(self):
""" Get license_type value.
Notes:
This attribute is named `licenseType` in VSD API.
"""
return self._license_type
@license_type.setter
def license_type(self, value):
""" Set license_type value.
Notes:
This attribute is named `licenseType` in VSD API.
"""
self._license_type = value
@property
def minor_release(self):
""" Get minor_release value.
Notes:
Minor software release for which this license has been issued
This attribute is named `minorRelease` in VSD API.
"""
return self._minor_release
@minor_release.setter
def minor_release(self, value):
""" Set minor_release value.
Notes:
Minor software release for which this license has been issued
This attribute is named `minorRelease` in VSD API.
"""
self._minor_release = value
@property
def zip(self):
""" Get zip value.
Notes:
Zipcode of the owner associated with the license file
"""
return self._zip
@zip.setter
def zip(self, value):
""" Set zip value.
Notes:
Zipcode of the owner associated with the license file
"""
self._zip = value
@property
def city(self):
""" Get city value.
Notes:
City of the owner associated with the license file
"""
return self._city
@city.setter
def city(self, value):
""" Set city value.
Notes:
City of the owner associated with the license file
"""
self._city = value
@property
def allowed_cpes_count(self):
""" Get allowed_cpes_count value.
Notes:
Maximum number of CPEs enabled with this license. A value of -1 indicates an unlimited number of CPEs
This attribute is named `allowedCPEsCount` in VSD API.
"""
return self._allowed_cpes_count
@allowed_cpes_count.setter
def allowed_cpes_count(self, value):
""" Set allowed_cpes_count value.
Notes:
Maximum number of CPEs enabled with this license. A value of -1 indicates an unlimited number of CPEs
This attribute is named `allowedCPEsCount` in VSD API.
"""
self._allowed_cpes_count = value
@property
def allowed_nics_count(self):
""" Get allowed_nics_count value.
Notes:
Maximum number of NICs allowed. A value of -1 indicates unlimited number of NICs
This attribute is named `allowedNICsCount` in VSD API.
"""
return self._allowed_nics_count
@allowed_nics_count.setter
def allowed_nics_count(self, value):
""" Set allowed_nics_count value.
Notes:
Maximum number of NICs allowed. A value of -1 indicates unlimited number of NICs
This attribute is named `allowedNICsCount` in VSD API.
"""
self._allowed_nics_count = value
@property
def allowed_vms_count(self):
""" Get allowed_vms_count value.
Notes:
Maximum number of VMs enabled with this license. A value of -1 indicates an unlimited number of VMs
This attribute is named `allowedVMsCount` in VSD API.
"""
return self._allowed_vms_count
@allowed_vms_count.setter
def allowed_vms_count(self, value):
""" Set allowed_vms_count value.
Notes:
Maximum number of VMs enabled with this license. A value of -1 indicates an unlimited number of VMs
This attribute is named `allowedVMsCount` in VSD API.
"""
self._allowed_vms_count = value
@property
def allowed_vrsgs_count(self):
""" Get allowed_vrsgs_count value.
Notes:
Maximum number of VRSGs enabled with this license. A value of -1 indicates an unlimited number of VRSGs
This attribute is named `allowedVRSGsCount` in VSD API.
"""
return self._allowed_vrsgs_count
@allowed_vrsgs_count.setter
def allowed_vrsgs_count(self, value):
""" Set allowed_vrsgs_count value.
Notes:
Maximum number of VRSGs enabled with this license. A value of -1 indicates an unlimited number of VRSGs
This attribute is named `allowedVRSGsCount` in VSD API.
"""
self._allowed_vrsgs_count = value
@property
def allowed_vrss_count(self):
""" Get allowed_vrss_count value.
Notes:
Maximum number of VRSs enabled with this license. A value of -1 indicates an unlimited number of VRSs
This attribute is named `allowedVRSsCount` in VSD API.
"""
return self._allowed_vrss_count
@allowed_vrss_count.setter
def allowed_vrss_count(self, value):
""" Set allowed_vrss_count value.
Notes:
Maximum number of VRSs enabled with this license. A value of -1 indicates an unlimited number of VRSs
This attribute is named `allowedVRSsCount` in VSD API.
"""
self._allowed_vrss_count = value
@property
def email(self):
""" Get email value.
Notes:
Email of the owner associated with the license file
"""
return self._email
@email.setter
def email(self, value):
""" Set email value.
Notes:
Email of the owner associated with the license file
"""
self._email = value
@property
def encryption_mode(self):
""" Get encryption_mode value.
Notes:
Indicates if the system is associated with a license that allows encryption or not
This attribute is named `encryptionMode` in VSD API.
"""
return self._encryption_mode
@encryption_mode.setter
def encryption_mode(self, value):
""" Set encryption_mode value.
Notes:
Indicates if the system is associated with a license that allows encryption or not
This attribute is named `encryptionMode` in VSD API.
"""
self._encryption_mode = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def company(self):
""" Get company value.
Notes:
Company of the owner associated with the license file
"""
return self._company
@company.setter
def company(self, value):
""" Set company value.
Notes:
Company of the owner associated with the license file
"""
self._company = value
@property
def country(self):
""" Get country value.
Notes:
Country of the owner associated with the license file
"""
return self._country
@country.setter
def country(self, value):
""" Set country value.
Notes:
Country of the owner associated with the license file
"""
self._country = value
@property
def product_version(self):
""" Get product_version value.
Notes:
Version of the product that this license applies to
This attribute is named `productVersion` in VSD API.
"""
return self._product_version
@product_version.setter
def product_version(self, value):
""" Set product_version value.
Notes:
Version of the product that this license applies to
This attribute is named `productVersion` in VSD API.
"""
self._product_version = value
@property
def provider(self):
""" Get provider value.
Notes:
Provider of the license file
"""
return self._provider
@provider.setter
def provider(self, value):
""" Set provider value.
Notes:
Provider of the license file
"""
self._provider = value
@property
def is_cluster_license(self):
""" Get is_cluster_license value.
Notes:
Indicates if the license is associated with standlone or cluster setup of VSD
This attribute is named `isClusterLicense` in VSD API.
"""
return self._is_cluster_license
@is_cluster_license.setter
def is_cluster_license(self, value):
""" Set is_cluster_license value.
Notes:
Indicates if the license is associated with standlone or cluster setup of VSD
This attribute is named `isClusterLicense` in VSD API.
"""
self._is_cluster_license = value
@property
def user_name(self):
""" Get user_name value.
Notes:
The name of the user associated with the license
This attribute is named `userName` in VSD API.
"""
return self._user_name
@user_name.setter
def user_name(self, value):
""" Set user_name value.
Notes:
The name of the user associated with the license
This attribute is named `userName` in VSD API.
"""
self._user_name = value
@property
def state(self):
""" Get state value.
Notes:
State of the owner associated with the license file
"""
return self._state
@state.setter
def state(self, value):
""" Set state value.
Notes:
State of the owner associated with the license file
"""
self._state = value
@property
def street(self):
""" Get street value.
Notes:
Address of the owner associated with the license file
"""
return self._street
@street.setter
def street(self, value):
""" Set street value.
Notes:
Address of the owner associated with the license file
"""
self._street = value
@property
def customer_key(self):
""" Get customer_key value.
Notes:
Customer key associated with the licese
This attribute is named `customerKey` in VSD API.
"""
return self._customer_key
@customer_key.setter
def customer_key(self, value):
""" Set customer_key value.
Notes:
Customer key associated with the licese
This attribute is named `customerKey` in VSD API.
"""
self._customer_key = value
@property
def expiration_date(self):
""" Get expiration_date value.
Notes:
Expiration date of this license
This attribute is named `expirationDate` in VSD API.
"""
return self._expiration_date
@expiration_date.setter
def expiration_date(self, value):
""" Set expiration_date value.
Notes:
Expiration date of this license
This attribute is named `expirationDate` in VSD API.
"""
self._expiration_date = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NULicense
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_LICENSE_ENCRYPTION_ENCRYPTION_DISABLED
var CONST_LICENSE_ENCRYPTION_ENCRYPTION_ENABLED
var CONST_LICENSE_TYPE_CLUSTERED
var CONST_LICENSE_TYPE_STANDARD
var resource_name
var rest_name
Instance variables
var allowed_cpes_count
Get allowed_cpes_count value.
Notes: Maximum number of CPEs enabled with this license. A value of -1 indicates an unlimited number of CPEs
This attribute is named `allowedCPEsCount` in VSD API.
var allowed_nics_count
Get allowed_nics_count value.
Notes: Maximum number of NICs allowed. A value of -1 indicates unlimited number of NICs
This attribute is named `allowedNICsCount` in VSD API.
var allowed_vms_count
Get allowed_vms_count value.
Notes: Maximum number of VMs enabled with this license. A value of -1 indicates an unlimited number of VMs
This attribute is named `allowedVMsCount` in VSD API.
var allowed_vrsgs_count
Get allowed_vrsgs_count value.
Notes: Maximum number of VRSGs enabled with this license. A value of -1 indicates an unlimited number of VRSGs
This attribute is named `allowedVRSGsCount` in VSD API.
var allowed_vrss_count
Get allowed_vrss_count value.
Notes: Maximum number of VRSs enabled with this license. A value of -1 indicates an unlimited number of VRSs
This attribute is named `allowedVRSsCount` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var city
Get city value.
Notes: City of the owner associated with the license file
var company
Get company value.
Notes: Company of the owner associated with the license file
var country
Get country value.
Notes: Country of the owner associated with the license file
var creation_date
Get creation date
var customer_key
Get customer_key value.
Notes: Customer key associated with the licese
This attribute is named `customerKey` in VSD API.
var email
Get email value.
Notes: Email of the owner associated with the license file
var encryption_mode
Get encryption_mode value.
Notes: Indicates if the system is associated with a license that allows encryption or not
This attribute is named `encryptionMode` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var expiration_date
Get expiration_date value.
Notes: Expiration date of this license
This attribute is named `expirationDate` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var is_cluster_license
Get is_cluster_license value.
Notes: Indicates if the license is associated with standlone or cluster setup of VSD
This attribute is named `isClusterLicense` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var license
Get license value.
Notes: Base 64 value of the license
var license_encryption
Get license_encryption value.
Notes: License encryption
This attribute is named `licenseEncryption` in VSD API.
var license_id
Get license_id value.
Notes: Unique identifier of the license file
This attribute is named `licenseID` in VSD API.
var license_type
Get license_type value.
Notes:
This attribute is named `licenseType` in VSD API.
var local_id
Get local id
var major_release
Get major_release value.
Notes: Major software release associated with this license
This attribute is named `majorRelease` in VSD API.
var metadatas
var minor_release
Get minor_release value.
Notes: Minor software release for which this license has been issued
This attribute is named `minorRelease` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var phone
Get phone value.
Notes: Phone number of the owner associated with the license file
var product_version
Get product_version value.
Notes: Version of the product that this license applies to
This attribute is named `productVersion` in VSD API.
var provider
Get provider value.
Notes: Provider of the license file
var state
Get state value.
Notes: State of the owner associated with the license file
var street
Get street value.
Notes: Address of the owner associated with the license file
var user_name
Get user_name value.
Notes: The name of the user associated with the license
This attribute is named `userName` in VSD API.
var zip
Get zip value.
Notes: Zipcode of the owner associated with the license file
Methods
def __init__(
self, **kwargs)
Initializes a License instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> license = NULicense(id=u'xxxx-xxx-xxx-xxx', name=u'License') >>> license = NULicense(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a License instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> license = NULicense(id=u'xxxx-xxx-xxx-xxx', name=u'License')
>>> license = NULicense(data=my_dict)
"""
super(NULicense, self).__init__()
# Read/Write Attributes
self._major_release = None
self._last_updated_by = None
self._phone = None
self._license = None
self._license_encryption = None
self._license_id = None
self._license_type = None
self._minor_release = None
self._zip = None
self._city = None
self._allowed_cpes_count = None
self._allowed_nics_count = None
self._allowed_vms_count = None
self._allowed_vrsgs_count = None
self._allowed_vrss_count = None
self._email = None
self._encryption_mode = None
self._entity_scope = None
self._company = None
self._country = None
self._product_version = None
self._provider = None
self._is_cluster_license = None
self._user_name = None
self._state = None
self._street = None
self._customer_key = None
self._expiration_date = None
self._external_id = None
self.expose_attribute(local_name="major_release", remote_name="majorRelease", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="phone", remote_name="phone", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="license", remote_name="license", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="license_encryption", remote_name="licenseEncryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENCRYPTION_DISABLED', u'ENCRYPTION_ENABLED'])
self.expose_attribute(local_name="license_id", remote_name="licenseID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="license_type", remote_name="licenseType", attribute_type=str, is_required=False, is_unique=False, choices=[u'CLUSTERED', u'STANDARD'])
self.expose_attribute(local_name="minor_release", remote_name="minorRelease", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="zip", remote_name="zip", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="city", remote_name="city", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_cpes_count", remote_name="allowedCPEsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_nics_count", remote_name="allowedNICsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_vms_count", remote_name="allowedVMsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_vrsgs_count", remote_name="allowedVRSGsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="allowed_vrss_count", remote_name="allowedVRSsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="email", remote_name="email", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption_mode", remote_name="encryptionMode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="company", remote_name="company", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="country", remote_name="country", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="provider", remote_name="provider", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="is_cluster_license", remote_name="isClusterLicense", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="state", remote_name="state", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="street", remote_name="street", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customer_key", remote_name="customerKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="expiration_date", remote_name="expirationDate", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NULocation
Represents a Location in the VSD
Notes: Gateway location details.
class NULocation(NURESTObject):
""" Represents a Location in the VSD
Notes:
Gateway location details.
"""
__rest_name__ = "location"
__resource_name__ = "locations"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a Location instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> location = NULocation(id=u'xxxx-xxx-xxx-xxx', name=u'Location')
>>> location = NULocation(data=my_dict)
"""
super(NULocation, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._latitude = None
self._address = None
self._ignore_geocode = None
self._time_zone_id = None
self._entity_scope = None
self._locality = None
self._longitude = None
self._country = None
self._state = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="latitude", remote_name="latitude", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ignore_geocode", remote_name="ignoreGeocode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="time_zone_id", remote_name="timeZoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="locality", remote_name="locality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="longitude", remote_name="longitude", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="country", remote_name="country", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="state", remote_name="state", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def latitude(self):
""" Get latitude value.
Notes:
Latitude in decimal format.
"""
return self._latitude
@latitude.setter
def latitude(self, value):
""" Set latitude value.
Notes:
Latitude in decimal format.
"""
self._latitude = value
@property
def address(self):
""" Get address value.
Notes:
Formatted address including property number, street name, suite or office number, ...
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
Formatted address including property number, street name, suite or office number, ...
"""
self._address = value
@property
def ignore_geocode(self):
""" Get ignore_geocode value.
Notes:
Request BSS to perform a geocode on the address - If no value passed, requestGeocode will be set to true
This attribute is named `ignoreGeocode` in VSD API.
"""
return self._ignore_geocode
@ignore_geocode.setter
def ignore_geocode(self, value):
""" Set ignore_geocode value.
Notes:
Request BSS to perform a geocode on the address - If no value passed, requestGeocode will be set to true
This attribute is named `ignoreGeocode` in VSD API.
"""
self._ignore_geocode = value
@property
def time_zone_id(self):
""" Get time_zone_id value.
Notes:
Time zone in which the Gateway is located. This can be in the form of a UTC/GMT offset, continent/city location, or country/region. The available time zones can be found in /usr/share/zoneinfo on a Linux machine or retrieved with TimeZone.getAvailableIDs() in Java. Refer to the IANA (Internet Assigned Numbers Authority) for a list of time zones. URL : http://www.iana.org/time-zones Default value is UTC (translating to Etc/Zulu)
This attribute is named `timeZoneID` in VSD API.
"""
return self._time_zone_id
@time_zone_id.setter
def time_zone_id(self, value):
""" Set time_zone_id value.
Notes:
Time zone in which the Gateway is located. This can be in the form of a UTC/GMT offset, continent/city location, or country/region. The available time zones can be found in /usr/share/zoneinfo on a Linux machine or retrieved with TimeZone.getAvailableIDs() in Java. Refer to the IANA (Internet Assigned Numbers Authority) for a list of time zones. URL : http://www.iana.org/time-zones Default value is UTC (translating to Etc/Zulu)
This attribute is named `timeZoneID` in VSD API.
"""
self._time_zone_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def locality(self):
""" Get locality value.
Notes:
Locality/City/County
"""
return self._locality
@locality.setter
def locality(self, value):
""" Set locality value.
Notes:
Locality/City/County
"""
self._locality = value
@property
def longitude(self):
""" Get longitude value.
Notes:
Longitude in decimal format.
"""
return self._longitude
@longitude.setter
def longitude(self, value):
""" Set longitude value.
Notes:
Longitude in decimal format.
"""
self._longitude = value
@property
def country(self):
""" Get country value.
Notes:
Country
"""
return self._country
@country.setter
def country(self, value):
""" Set country value.
Notes:
Country
"""
self._country = value
@property
def state(self):
""" Get state value.
Notes:
State/Province/Region
"""
return self._state
@state.setter
def state(self, value):
""" Set state value.
Notes:
State/Province/Region
"""
self._state = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NULocation
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: Formatted address including property number, street name, suite or office number, ...
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var country
Get country value.
Notes: Country
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ignore_geocode
Get ignore_geocode value.
Notes: Request BSS to perform a geocode on the address - If no value passed, requestGeocode will be set to true
This attribute is named `ignoreGeocode` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var latitude
Get latitude value.
Notes: Latitude in decimal format.
var local_id
Get local id
var locality
Get locality value.
Notes: Locality/City/County
var longitude
Get longitude value.
Notes: Longitude in decimal format.
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var state
Get state value.
Notes: State/Province/Region
var time_zone_id
Get time_zone_id value.
Notes: Time zone in which the Gateway is located. This can be in the form of a UTC/GMT offset, continent/city location, or country/region. The available time zones can be found in /usr/share/zoneinfo on a Linux machine or retrieved with TimeZone.getAvailableIDs() in Java. Refer to the IANA (Internet Assigned Numbers Authority) for a list of time zones. URL : http://www.iana.org/time-zones Default value is UTC (translating to Etc/Zulu)
This attribute is named `timeZoneID` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a Location instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> location = NULocation(id=u'xxxx-xxx-xxx-xxx', name=u'Location') >>> location = NULocation(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Location instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> location = NULocation(id=u'xxxx-xxx-xxx-xxx', name=u'Location')
>>> location = NULocation(data=my_dict)
"""
super(NULocation, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._latitude = None
self._address = None
self._ignore_geocode = None
self._time_zone_id = None
self._entity_scope = None
self._locality = None
self._longitude = None
self._country = None
self._state = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="latitude", remote_name="latitude", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ignore_geocode", remote_name="ignoreGeocode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="time_zone_id", remote_name="timeZoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="locality", remote_name="locality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="longitude", remote_name="longitude", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="country", remote_name="country", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="state", remote_name="state", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMe
Represents a Me in the VSD
Notes: Object that identifies the user functions
class NUMe(NURESTRootObject):
""" Represents a Me in the VSD
Notes:
Object that identifies the user functions
"""
__rest_name__ = "me"
__resource_name__ = "me"
## Constants
CONST_AVATAR_TYPE_URL = "URL"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_AVATAR_TYPE_BASE64 = "BASE64"
CONST_AVATAR_TYPE_COMPUTEDURL = "COMPUTEDURL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a Me instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> me = NUMe(id=u'xxxx-xxx-xxx-xxx', name=u'Me')
>>> me = NUMe(data=my_dict)
"""
super(NUMe, self).__init__()
# Read/Write Attributes
self._password = None
self._last_name = None
self._last_updated_by = None
self._first_name = None
self._disabled = None
self._email = None
self._enterprise_id = None
self._enterprise_name = None
self._entity_scope = None
self._mobile_number = None
self._role = None
self._user_name = None
self._avatar_data = None
self._avatar_type = None
self._external_id = None
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_name", remote_name="lastName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="first_name", remote_name="firstName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="disabled", remote_name="disabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="email", remote_name="email", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_name", remote_name="enterpriseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="mobile_number", remote_name="mobileNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="role", remote_name="role", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="avatar_data", remote_name="avatarData", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_type", remote_name="avatarType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BASE64', u'COMPUTEDURL', u'URL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.l2_domains = NUL2DomainsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenter_eam_configs = NUVCenterEAMConfigsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.rate_limiters = NURateLimitersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.gateways = NUGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.gateway_templates = NUGatewayTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.patnat_pools = NUPATNATPoolsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenters = NUVCentersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenter_hypervisors = NUVCenterHypervisorsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.redundancy_groups = NURedundancyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.certificates = NUCertificatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.network_layouts = NUNetworkLayoutsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.key_server_members = NUKeyServerMembersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.domain_fip_acl_templates = NUDomainFIPAclTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.floating_ipacl_templates = NUFloatingIPACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.egress_qos_policies = NUEgressQOSPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.shared_network_resources = NUSharedNetworkResourcesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.licenses = NULicensesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.mirror_destinations = NUMirrorDestinationsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.site_infos = NUSiteInfosFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.floating_ips = NUFloatingIpsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.cloud_mgmt_systems = NUCloudMgmtSystemsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.infrastructure_gateway_profiles = NUInfrastructureGatewayProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.infrastructure_port_profiles = NUInfrastructurePortProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.infrastructure_vsc_profiles = NUInfrastructureVscProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ingress_adv_fwd_entry_templates = NUIngressAdvFwdEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.enterprises = NUEnterprisesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.enterprise_profiles = NUEnterpriseProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.domains = NUDomainsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.zones = NUZonesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.uplink_rds = NUUplinkRDsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.application_services = NUApplicationServicesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenter_vrs_configs = NUVCenterVRSConfigsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.users = NUUsersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_gateways = NUNSGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_gateway_templates = NUNSGatewayTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_redundant_gateway_groups = NUNSRedundantGatewayGroupsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vsps = NUVSPsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_port_static_configurations = NUNSPortStaticConfigurationsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.stats_collector_infos = NUStatsCollectorInfosFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.auto_discovered_gateways = NUAutoDiscoveredGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.external_app_services = NUExternalAppServicesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.external_services = NUExternalServicesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.system_configs = NUSystemConfigsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self._compute_args(**kwargs)
# Properties
@property
def password(self):
""" Get password value.
Notes:
User password stored as a hash (SHA-1 encrpted)
"""
return self._password
@password.setter
def password(self, value):
""" Set password value.
Notes:
User password stored as a hash (SHA-1 encrpted)
"""
self._password = value
@property
def last_name(self):
""" Get last_name value.
Notes:
Last name of the user
This attribute is named `lastName` in VSD API.
"""
return self._last_name
@last_name.setter
def last_name(self, value):
""" Set last_name value.
Notes:
Last name of the user
This attribute is named `lastName` in VSD API.
"""
self._last_name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def first_name(self):
""" Get first_name value.
Notes:
First name of the user
This attribute is named `firstName` in VSD API.
"""
return self._first_name
@first_name.setter
def first_name(self, value):
""" Set first_name value.
Notes:
First name of the user
This attribute is named `firstName` in VSD API.
"""
self._first_name = value
@property
def disabled(self):
""" Get disabled value.
Notes:
Status of the user account; true=disabled, false=not disabled; default value = false
"""
return self._disabled
@disabled.setter
def disabled(self, value):
""" Set disabled value.
Notes:
Status of the user account; true=disabled, false=not disabled; default value = false
"""
self._disabled = value
@property
def email(self):
""" Get email value.
Notes:
Email address of the user
"""
return self._email
@email.setter
def email(self, value):
""" Set email value.
Notes:
Email address of the user
"""
self._email = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
Identifier of the enterprise.
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
Identifier of the enterprise.
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def enterprise_name(self):
""" Get enterprise_name value.
Notes:
Name of the enterprise.
This attribute is named `enterpriseName` in VSD API.
"""
return self._enterprise_name
@enterprise_name.setter
def enterprise_name(self, value):
""" Set enterprise_name value.
Notes:
Name of the enterprise.
This attribute is named `enterpriseName` in VSD API.
"""
self._enterprise_name = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def mobile_number(self):
""" Get mobile_number value.
Notes:
Mobile Number of the user
This attribute is named `mobileNumber` in VSD API.
"""
return self._mobile_number
@mobile_number.setter
def mobile_number(self, value):
""" Set mobile_number value.
Notes:
Mobile Number of the user
This attribute is named `mobileNumber` in VSD API.
"""
self._mobile_number = value
@property
def role(self):
""" Get role value.
Notes:
Role of the user.
"""
return self._role
@role.setter
def role(self, value):
""" Set role value.
Notes:
Role of the user.
"""
self._role = value
@property
def user_name(self):
""" Get user_name value.
Notes:
Unique Username of the user. Valid characters are alphabets, numbers and hyphen( - ).
This attribute is named `userName` in VSD API.
"""
return self._user_name
@user_name.setter
def user_name(self, value):
""" Set user_name value.
Notes:
Unique Username of the user. Valid characters are alphabets, numbers and hyphen( - ).
This attribute is named `userName` in VSD API.
"""
self._user_name = value
@property
def avatar_data(self):
""" Get avatar_data value.
Notes:
URL to the avatar data associated with the enterprise. If the avatarType is URL then value of avatarData should an URL of the image. If the avatarType BASE64 then avatarData should be BASE64 encoded value of the image
This attribute is named `avatarData` in VSD API.
"""
return self._avatar_data
@avatar_data.setter
def avatar_data(self, value):
""" Set avatar_data value.
Notes:
URL to the avatar data associated with the enterprise. If the avatarType is URL then value of avatarData should an URL of the image. If the avatarType BASE64 then avatarData should be BASE64 encoded value of the image
This attribute is named `avatarData` in VSD API.
"""
self._avatar_data = value
@property
def avatar_type(self):
""" Get avatar_type value.
Notes:
Avatar type.
This attribute is named `avatarType` in VSD API.
"""
return self._avatar_type
@avatar_type.setter
def avatar_type(self, value):
""" Set avatar_type value.
Notes:
Avatar type.
This attribute is named `avatarType` in VSD API.
"""
self._avatar_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMe
- bambou.nurest_root_object.NURESTRootObject
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_AVATAR_TYPE_BASE64
var CONST_AVATAR_TYPE_COMPUTEDURL
var CONST_AVATAR_TYPE_URL
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var api_key
Get API Key
var application_services
var auto_discovered_gateways
var avatar_data
Get avatar_data value.
Notes: URL to the avatar data associated with the enterprise. If the avatarType is URL then value of avatarData should an URL of the image. If the avatarType BASE64 then avatarData should be BASE64 encoded value of the image
This attribute is named `avatarData` in VSD API.
var avatar_type
Get avatar_type value.
Notes: Avatar type.
This attribute is named `avatarType` in VSD API.
var certificates
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var cloud_mgmt_systems
var creation_date
Get creation date
var disabled
Get disabled value.
Notes: Status of the user account; true=disabled, false=not disabled; default value = false
var domain_fip_acl_templates
var domains
var egress_acl_entry_templates
var egress_acl_templates
var egress_qos_policies
var email
Get email value.
Notes: Email address of the user
var enterprise_id
Get enterprise_id value.
Notes: Identifier of the enterprise.
This attribute is named `enterpriseID` in VSD API.
var enterprise_name
Get enterprise_name value.
Notes: Name of the enterprise.
This attribute is named `enterpriseName` in VSD API.
var enterprise_profiles
var enterprises
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_app_services
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var external_services
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var first_name
Get first_name value.
Notes: First name of the user
This attribute is named `firstName` in VSD API.
var floating_ipacl_templates
var floating_ips
var gateway_templates
var gateways
var global_metadatas
var host_interfaces
var id
Get object id
var infrastructure_gateway_profiles
var infrastructure_port_profiles
var infrastructure_vsc_profiles
var ingress_acl_entry_templates
var ingress_acl_templates
var ingress_adv_fwd_entry_templates
var jobs
var key_server_members
var l2_domains
var last_name
Get last_name value.
Notes: Last name of the user
This attribute is named `lastName` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var licenses
var local_id
Get local id
var metadatas
var mirror_destinations
var mobile_number
Get mobile_number value.
Notes: Mobile Number of the user
This attribute is named `mobileNumber` in VSD API.
var multi_cast_channel_maps
var network_layouts
var ns_gateway_templates
var ns_gateways
var ns_port_static_configurations
var ns_redundant_gateway_groups
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var password
Get password value.
Notes: User password stored as a hash (SHA-1 encrpted)
var patnat_pools
var policy_groups
var rate_limiters
var redirection_targets
var redundancy_groups
var role
Get role value.
Notes: Role of the user.
var site_infos
var static_routes
var stats_collector_infos
var subnets
var system_configs
var tcas
var uplink_rds
var user_name
Get user_name value.
Notes: Unique Username of the user. Valid characters are alphabets, numbers and hyphen( - ).
This attribute is named `userName` in VSD API.
var users
var vcenter_eam_configs
var vcenter_hypervisors
var vcenter_vrs_configs
var vcenters
var vm_interfaces
var vms
var vsps
var zones
Methods
def __init__(
self, **kwargs)
Initializes a Me instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> me = NUMe(id=u'xxxx-xxx-xxx-xxx', name=u'Me') >>> me = NUMe(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Me instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> me = NUMe(id=u'xxxx-xxx-xxx-xxx', name=u'Me')
>>> me = NUMe(data=my_dict)
"""
super(NUMe, self).__init__()
# Read/Write Attributes
self._password = None
self._last_name = None
self._last_updated_by = None
self._first_name = None
self._disabled = None
self._email = None
self._enterprise_id = None
self._enterprise_name = None
self._entity_scope = None
self._mobile_number = None
self._role = None
self._user_name = None
self._avatar_data = None
self._avatar_type = None
self._external_id = None
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_name", remote_name="lastName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="first_name", remote_name="firstName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="disabled", remote_name="disabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="email", remote_name="email", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_name", remote_name="enterpriseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="mobile_number", remote_name="mobileNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="role", remote_name="role", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="avatar_data", remote_name="avatarData", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_type", remote_name="avatarType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BASE64', u'COMPUTEDURL', u'URL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.l2_domains = NUL2DomainsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenter_eam_configs = NUVCenterEAMConfigsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.rate_limiters = NURateLimitersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.gateways = NUGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.gateway_templates = NUGatewayTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.patnat_pools = NUPATNATPoolsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenters = NUVCentersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenter_hypervisors = NUVCenterHypervisorsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.redundancy_groups = NURedundancyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.certificates = NUCertificatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.network_layouts = NUNetworkLayoutsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.key_server_members = NUKeyServerMembersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.egress_acl_entry_templates = NUEgressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.egress_acl_templates = NUEgressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.domain_fip_acl_templates = NUDomainFIPAclTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.floating_ipacl_templates = NUFloatingIPACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.egress_qos_policies = NUEgressQOSPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.shared_network_resources = NUSharedNetworkResourcesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.licenses = NULicensesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.mirror_destinations = NUMirrorDestinationsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.site_infos = NUSiteInfosFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.floating_ips = NUFloatingIpsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.cloud_mgmt_systems = NUCloudMgmtSystemsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.infrastructure_gateway_profiles = NUInfrastructureGatewayProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.infrastructure_port_profiles = NUInfrastructurePortProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.infrastructure_vsc_profiles = NUInfrastructureVscProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ingress_acl_entry_templates = NUIngressACLEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ingress_acl_templates = NUIngressACLTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ingress_adv_fwd_entry_templates = NUIngressAdvFwdEntryTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.enterprises = NUEnterprisesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.enterprise_profiles = NUEnterpriseProfilesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.domains = NUDomainsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.zones = NUZonesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.uplink_rds = NUUplinkRDsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.application_services = NUApplicationServicesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vcenter_vrs_configs = NUVCenterVRSConfigsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.users = NUUsersFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_gateways = NUNSGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_gateway_templates = NUNSGatewayTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_redundant_gateway_groups = NUNSRedundantGatewayGroupsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.vsps = NUVSPsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.ns_port_static_configurations = NUNSPortStaticConfigurationsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.stats_collector_infos = NUStatsCollectorInfosFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.auto_discovered_gateways = NUAutoDiscoveredGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.external_app_services = NUExternalAppServicesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.external_services = NUExternalServicesFetcher.fetcher_with_object(parent_object=self, relationship="root")
self.system_configs = NUSystemConfigsFetcher.fetcher_with_object(parent_object=self, relationship="root")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_fetch, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_default_root_object(
cls)
Get default user
@classmethod
def get_default_root_object(cls):
""" Get default user """
if not cls.__default_root_object:
NURESTRootObject.__default_root_object = cls()
return NURESTRootObject.__default_root_object
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.rest_base_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def prepare_change_password(
self, new_password)
Prepares password modification
def prepare_change_password(self, new_password):
""" Prepares password modification """
self._new_password = new_password
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, async=False, callback=None)
Updates the user and perform the callback method
def save(self, async=False, callback=None):
""" Updates the user and perform the callback method """
if self._new_password:
self.password = Sha1.encrypt(self._new_password)
controller = _NURESTSessionCurrentContext.session.login_controller
controller.password = self._new_password
controller.api_key = None
data = json.dumps(self.to_dict())
request = NURESTRequest(method=HTTP_METHOD_PUT, url=self.get_resource_url(), data=data)
if async:
return self.send_request(request=request, async=async, local_callback=self._did_save, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_save(connection)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMetadata
Represents a Metadata in the VSD
Notes: Metadata associated to a entity.
class NUMetadata(NURESTObject):
""" Represents a Metadata in the VSD
Notes:
Metadata associated to a entity.
"""
__rest_name__ = "metadata"
__resource_name__ = "metadatas"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a Metadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> metadata = NUMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'Metadata')
>>> metadata = NUMetadata(data=my_dict)
"""
super(NUMetadata, self).__init__()
# Read/Write Attributes
self._name = None
self._description = None
self._metadata_tag_ids = None
self._network_notification_disabled = None
self._blob = None
self._global_metadata = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_tag_ids", remote_name="metadataTagIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_notification_disabled", remote_name="networkNotificationDisabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="blob", remote_name="blob", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="global_metadata", remote_name="global", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
name of the Metadata.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
name of the Metadata.
"""
self._name = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Metadata.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Metadata.
"""
self._description = value
@property
def metadata_tag_ids(self):
""" Get metadata_tag_ids value.
Notes:
metadata tag IDs associated with this metadata you can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
"""
return self._metadata_tag_ids
@metadata_tag_ids.setter
def metadata_tag_ids(self, value):
""" Set metadata_tag_ids value.
Notes:
metadata tag IDs associated with this metadata you can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
"""
self._metadata_tag_ids = value
@property
def network_notification_disabled(self):
""" Get network_notification_disabled value.
Notes:
specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
"""
return self._network_notification_disabled
@network_notification_disabled.setter
def network_notification_disabled(self, value):
""" Set network_notification_disabled value.
Notes:
specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
"""
self._network_notification_disabled = value
@property
def blob(self):
""" Get blob value.
Notes:
Metadata that describes about the entity attached to it.
"""
return self._blob
@blob.setter
def blob(self, value):
""" Set blob value.
Notes:
Metadata that describes about the entity attached to it.
"""
self._blob = value
@property
def global_metadata(self):
""" Get global_metadata value.
Notes:
specifies metadata is global or local
This attribute is named `global` in VSD API.
"""
return self._global_metadata
@global_metadata.setter
def global_metadata(self, value):
""" Set global_metadata value.
Notes:
specifies metadata is global or local
This attribute is named `global` in VSD API.
"""
self._global_metadata = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMetadata
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var blob
Get blob value.
Notes: Metadata that describes about the entity attached to it.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the Metadata.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadata
Get global_metadata value.
Notes: specifies metadata is global or local
This attribute is named `global` in VSD API.
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_tag_ids
Get metadata_tag_ids value.
Notes: metadata tag IDs associated with this metadata you can filter metadata based on this attribute for example X-Nuage-Filter: '2d6fb627-603b-421c-b63a-eb0a6d712761' IN metadataTagIDs
This attribute is named `metadataTagIDs` in VSD API.
var name
Get name value.
Notes: name of the Metadata.
var network_notification_disabled
Get network_notification_disabled value.
Notes: specifies metadata changes need to be notified to controller,by default it is notified
This attribute is named `networkNotificationDisabled` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a Metadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> metadata = NUMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'Metadata') >>> metadata = NUMetadata(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Metadata instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> metadata = NUMetadata(id=u'xxxx-xxx-xxx-xxx', name=u'Metadata')
>>> metadata = NUMetadata(data=my_dict)
"""
super(NUMetadata, self).__init__()
# Read/Write Attributes
self._name = None
self._description = None
self._metadata_tag_ids = None
self._network_notification_disabled = None
self._blob = None
self._global_metadata = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_tag_ids", remote_name="metadataTagIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_notification_disabled", remote_name="networkNotificationDisabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="blob", remote_name="blob", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="global_metadata", remote_name="global", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadata_tags = NUMetadataTagsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMetadataTag
Represents a MetadataTag in the VSD
Notes: Metadata tag associated to a metadata.
class NUMetadataTag(NURESTObject):
""" Represents a MetadataTag in the VSD
Notes:
Metadata tag associated to a metadata.
"""
__rest_name__ = "metadatatag"
__resource_name__ = "metadatatags"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a MetadataTag instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> metadatatag = NUMetadataTag(id=u'xxxx-xxx-xxx-xxx', name=u'MetadataTag')
>>> metadatatag = NUMetadataTag(data=my_dict)
"""
super(NUMetadataTag, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._associated_external_service_id = None
self._auto_created = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_external_service_id", remote_name="associatedExternalServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_created", remote_name="autoCreated", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
name of the Metadata tag.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
name of the Metadata tag.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Metadata tag.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Metadata tag.
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_external_service_id(self):
""" Get associated_external_service_id value.
Notes:
ID of the entity to which the Metadata tag is associated to
This attribute is named `associatedExternalServiceID` in VSD API.
"""
return self._associated_external_service_id
@associated_external_service_id.setter
def associated_external_service_id(self, value):
""" Set associated_external_service_id value.
Notes:
ID of the entity to which the Metadata tag is associated to
This attribute is named `associatedExternalServiceID` in VSD API.
"""
self._associated_external_service_id = value
@property
def auto_created(self):
""" Get auto_created value.
Notes:
set to true if it is the default metadata tag created as part of external service creation
This attribute is named `autoCreated` in VSD API.
"""
return self._auto_created
@auto_created.setter
def auto_created(self, value):
""" Set auto_created value.
Notes:
set to true if it is the default metadata tag created as part of external service creation
This attribute is named `autoCreated` in VSD API.
"""
self._auto_created = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMetadataTag
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_external_service_id
Get associated_external_service_id value.
Notes: ID of the entity to which the Metadata tag is associated to
This attribute is named `associatedExternalServiceID` in VSD API.
var auto_created
Get auto_created value.
Notes: set to true if it is the default metadata tag created as part of external service creation
This attribute is named `autoCreated` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the Metadata tag.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: name of the Metadata tag.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a MetadataTag instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> metadatatag = NUMetadataTag(id=u'xxxx-xxx-xxx-xxx', name=u'MetadataTag') >>> metadatatag = NUMetadataTag(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a MetadataTag instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> metadatatag = NUMetadataTag(id=u'xxxx-xxx-xxx-xxx', name=u'MetadataTag')
>>> metadatatag = NUMetadataTag(data=my_dict)
"""
super(NUMetadataTag, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._associated_external_service_id = None
self._auto_created = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_external_service_id", remote_name="associatedExternalServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_created", remote_name="autoCreated", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMirrorDestination
Represents a MirrorDestination in the VSD
Notes: Represents a mirror destination.
class NUMirrorDestination(NURESTObject):
""" Represents a MirrorDestination in the VSD
Notes:
Represents a mirror destination.
"""
__rest_name__ = "mirrordestination"
__resource_name__ = "mirrordestinations"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a MirrorDestination instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> mirrordestination = NUMirrorDestination(id=u'xxxx-xxx-xxx-xxx', name=u'MirrorDestination')
>>> mirrordestination = NUMirrorDestination(data=my_dict)
"""
super(NUMirrorDestination, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._service_id = None
self._destination_ip = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id", remote_name="serviceId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_ip", remote_name="destinationIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vport_mirrors = NUVPortMirrorsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the mirror destination. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the mirror destination. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def service_id(self):
""" Get service_id value.
Notes:
Service ID of the mirror destination.
This attribute is named `serviceId` in VSD API.
"""
return self._service_id
@service_id.setter
def service_id(self, value):
""" Set service_id value.
Notes:
Service ID of the mirror destination.
This attribute is named `serviceId` in VSD API.
"""
self._service_id = value
@property
def destination_ip(self):
""" Get destination_ip value.
Notes:
IP address of the destination server where you want your traffic to be mirrored.
This attribute is named `destinationIp` in VSD API.
"""
return self._destination_ip
@destination_ip.setter
def destination_ip(self, value):
""" Set destination_ip value.
Notes:
IP address of the destination server where you want your traffic to be mirrored.
This attribute is named `destinationIp` in VSD API.
"""
self._destination_ip = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMirrorDestination
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var destination_ip
Get destination_ip value.
Notes: IP address of the destination server where you want your traffic to be mirrored.
This attribute is named `destinationIp` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the mirror destination. Valid characters are alphabets, numbers, space and hyphen( - ).
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var service_id
Get service_id value.
Notes: Service ID of the mirror destination.
This attribute is named `serviceId` in VSD API.
var vport_mirrors
Methods
def __init__(
self, **kwargs)
Initializes a MirrorDestination instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> mirrordestination = NUMirrorDestination(id=u'xxxx-xxx-xxx-xxx', name=u'MirrorDestination') >>> mirrordestination = NUMirrorDestination(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a MirrorDestination instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> mirrordestination = NUMirrorDestination(id=u'xxxx-xxx-xxx-xxx', name=u'MirrorDestination')
>>> mirrordestination = NUMirrorDestination(data=my_dict)
"""
super(NUMirrorDestination, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._service_id = None
self._destination_ip = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id", remote_name="serviceId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="destination_ip", remote_name="destinationIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vport_mirrors = NUVPortMirrorsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMonitoringPort
Represents a MonitoringPort in the VSD
Notes: Encapsulates the port information for system monitoring entity.
class NUMonitoringPort(NURESTObject):
""" Represents a MonitoringPort in the VSD
Notes:
Encapsulates the port information for system monitoring entity.
"""
__rest_name__ = "monitoringport"
__resource_name__ = "monitoringports"
## Constants
CONST_RESILIENCY_STATE_BACKUP = "backup"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_RESILIENCY_STATE_NONE = "none"
CONST_RESILIENCY_STATE_MASTER = "master"
CONST_STATE_DOWN = "DOWN"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_STATE_ADMIN_DOWN = "ADMIN_DOWN"
CONST_STATE_UP = "UP"
def __init__(self, **kwargs):
""" Initializes a MonitoringPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> monitoringport = NUMonitoringPort(id=u'xxxx-xxx-xxx-xxx', name=u'MonitoringPort')
>>> monitoringport = NUMonitoringPort(data=my_dict)
"""
super(NUMonitoringPort, self).__init__()
# Read/Write Attributes
self._name = None
self._last_state_change = None
self._access = None
self._description = None
self._resiliency_state = None
self._resilient = None
self._entity_scope = None
self._uplink = None
self._state = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="access", remote_name="access", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="resiliency_state", remote_name="resiliencyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'backup', u'master', u'none'])
self.expose_attribute(local_name="resilient", remote_name="resilient", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="uplink", remote_name="uplink", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="state", remote_name="state", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name for the port.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name for the port.
"""
self._name = value
@property
def last_state_change(self):
""" Get last_state_change value.
Notes:
Last port state change timestamp.
This attribute is named `lastStateChange` in VSD API.
"""
return self._last_state_change
@last_state_change.setter
def last_state_change(self, value):
""" Set last_state_change value.
Notes:
Last port state change timestamp.
This attribute is named `lastStateChange` in VSD API.
"""
self._last_state_change = value
@property
def access(self):
""" Get access value.
Notes:
Flag to indicate that it is a access port or network port.
"""
return self._access
@access.setter
def access(self, value):
""" Set access value.
Notes:
Flag to indicate that it is a access port or network port.
"""
self._access = value
@property
def description(self):
""" Get description value.
Notes:
Optional port description.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Optional port description.
"""
self._description = value
@property
def resiliency_state(self):
""" Get resiliency_state value.
Notes:
This attribute is named `resiliencyState` in VSD API.
"""
return self._resiliency_state
@resiliency_state.setter
def resiliency_state(self, value):
""" Set resiliency_state value.
Notes:
This attribute is named `resiliencyState` in VSD API.
"""
self._resiliency_state = value
@property
def resilient(self):
""" Get resilient value.
Notes:
Flag to indicate if an ACCESS port is resilient or not.
"""
return self._resilient
@resilient.setter
def resilient(self, value):
""" Set resilient value.
Notes:
Flag to indicate if an ACCESS port is resilient or not.
"""
self._resilient = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def uplink(self):
""" Get uplink value.
Notes:
Flag to indicate that is an uplink or downlink port.
"""
return self._uplink
@uplink.setter
def uplink(self, value):
""" Set uplink value.
Notes:
Flag to indicate that is an uplink or downlink port.
"""
self._uplink = value
@property
def state(self):
""" Get state value.
Notes:
The current state of the port.
"""
return self._state
@state.setter
def state(self, value):
""" Set state value.
Notes:
The current state of the port.
"""
self._state = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMonitoringPort
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_RESILIENCY_STATE_BACKUP
var CONST_RESILIENCY_STATE_MASTER
var CONST_RESILIENCY_STATE_NONE
var CONST_STATE_ADMIN_DOWN
var CONST_STATE_DOWN
var CONST_STATE_UP
var resource_name
var rest_name
Instance variables
var access
Get access value.
Notes: Flag to indicate that it is a access port or network port.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Optional port description.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_state_change
Get last_state_change value.
Notes: Last port state change timestamp.
This attribute is named `lastStateChange` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name for the port.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var resiliency_state
Get resiliency_state value.
Notes:
This attribute is named `resiliencyState` in VSD API.
var resilient
Get resilient value.
Notes: Flag to indicate if an ACCESS port is resilient or not.
var state
Get state value.
Notes: The current state of the port.
var uplink
Get uplink value.
Notes: Flag to indicate that is an uplink or downlink port.
Methods
def __init__(
self, **kwargs)
Initializes a MonitoringPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> monitoringport = NUMonitoringPort(id=u'xxxx-xxx-xxx-xxx', name=u'MonitoringPort') >>> monitoringport = NUMonitoringPort(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a MonitoringPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> monitoringport = NUMonitoringPort(id=u'xxxx-xxx-xxx-xxx', name=u'MonitoringPort')
>>> monitoringport = NUMonitoringPort(data=my_dict)
"""
super(NUMonitoringPort, self).__init__()
# Read/Write Attributes
self._name = None
self._last_state_change = None
self._access = None
self._description = None
self._resiliency_state = None
self._resilient = None
self._entity_scope = None
self._uplink = None
self._state = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="access", remote_name="access", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="resiliency_state", remote_name="resiliencyState", attribute_type=str, is_required=False, is_unique=False, choices=[u'backup', u'master', u'none'])
self.expose_attribute(local_name="resilient", remote_name="resilient", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="uplink", remote_name="uplink", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="state", remote_name="state", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMultiCastChannelMap
Represents a MultiCastChannelMap in the VSD
Notes: This is the definition of a MultiCast Channel Map.
class NUMultiCastChannelMap(NURESTObject):
""" Represents a MultiCastChannelMap in the VSD
Notes:
This is the definition of a MultiCast Channel Map.
"""
__rest_name__ = "multicastchannelmap"
__resource_name__ = "multicastchannelmaps"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a MultiCastChannelMap instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multicastchannelmap = NUMultiCastChannelMap(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastChannelMap')
>>> multicastchannelmap = NUMultiCastChannelMap(data=my_dict)
"""
super(NUMultiCastChannelMap, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_ranges = NUMultiCastRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the current entity
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the current entity
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description field provided by the user that identifies the MultiCast Channel Map
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description field provided by the user that identifies the MultiCast Channel Map
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMultiCastChannelMap
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description field provided by the user that identifies the MultiCast Channel Map
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var multi_cast_ranges
var name
Get name value.
Notes: Name of the current entity
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a MultiCastChannelMap instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> multicastchannelmap = NUMultiCastChannelMap(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastChannelMap') >>> multicastchannelmap = NUMultiCastChannelMap(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a MultiCastChannelMap instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multicastchannelmap = NUMultiCastChannelMap(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastChannelMap')
>>> multicastchannelmap = NUMultiCastChannelMap(data=my_dict)
"""
super(NUMultiCastChannelMap, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_ranges = NUMultiCastRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMultiCastList
Represents a MultiCastList in the VSD
Notes: This is the definition of a MultiCast Channel List.
class NUMultiCastList(NURESTObject):
""" Represents a MultiCastList in the VSD
Notes:
This is the definition of a MultiCast Channel List.
"""
__rest_name__ = "multicastlist"
__resource_name__ = "multicastlists"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_MCAST_TYPE_RECEIVE = "RECEIVE"
CONST_MCAST_TYPE_SEND = "SEND"
def __init__(self, **kwargs):
""" Initializes a MultiCastList instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multicastlist = NUMultiCastList(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastList')
>>> multicastlist = NUMultiCastList(data=my_dict)
"""
super(NUMultiCastList, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._mcast_type = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mcast_type", remote_name="mcastType", attribute_type=str, is_required=False, is_unique=False, choices=[u'RECEIVE', u'SEND'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def mcast_type(self):
""" Get mcast_type value.
Notes:
Type of multicast list.
This attribute is named `mcastType` in VSD API.
"""
return self._mcast_type
@mcast_type.setter
def mcast_type(self, value):
""" Set mcast_type value.
Notes:
Type of multicast list.
This attribute is named `mcastType` in VSD API.
"""
self._mcast_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMultiCastList
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MCAST_TYPE_RECEIVE
var CONST_MCAST_TYPE_SEND
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var mcast_type
Get mcast_type value.
Notes: Type of multicast list.
This attribute is named `mcastType` in VSD API.
var metadatas
var multi_cast_channel_maps
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a MultiCastList instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> multicastlist = NUMultiCastList(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastList') >>> multicastlist = NUMultiCastList(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a MultiCastList instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multicastlist = NUMultiCastList(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastList')
>>> multicastlist = NUMultiCastList(data=my_dict)
"""
super(NUMultiCastList, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._mcast_type = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mcast_type", remote_name="mcastType", attribute_type=str, is_required=False, is_unique=False, choices=[u'RECEIVE', u'SEND'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMultiCastRange
Represents a MultiCastRange in the VSD
Notes: This is the definition of a MultiCast Range associated with a MultiCast Channel Map.
class NUMultiCastRange(NURESTObject):
""" Represents a MultiCastRange in the VSD
Notes:
This is the definition of a MultiCast Range associated with a MultiCast Channel Map.
"""
__rest_name__ = "multicastrange"
__resource_name__ = "multicastranges"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a MultiCastRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multicastrange = NUMultiCastRange(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastRange')
>>> multicastrange = NUMultiCastRange(data=my_dict)
"""
super(NUMultiCastRange, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._max_address = None
self._min_address = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_address", remote_name="maxAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="min_address", remote_name="minAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def max_address(self):
""" Get max_address value.
Notes:
Highest address in the MultiCast range
This attribute is named `maxAddress` in VSD API.
"""
return self._max_address
@max_address.setter
def max_address(self, value):
""" Set max_address value.
Notes:
Highest address in the MultiCast range
This attribute is named `maxAddress` in VSD API.
"""
self._max_address = value
@property
def min_address(self):
""" Get min_address value.
Notes:
Lowest address in the MultiCast range
This attribute is named `minAddress` in VSD API.
"""
return self._min_address
@min_address.setter
def min_address(self, value):
""" Set min_address value.
Notes:
Lowest address in the MultiCast range
This attribute is named `minAddress` in VSD API.
"""
self._min_address = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMultiCastRange
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var max_address
Get max_address value.
Notes: Highest address in the MultiCast range
This attribute is named `maxAddress` in VSD API.
var metadatas
var min_address
Get min_address value.
Notes: Lowest address in the MultiCast range
This attribute is named `minAddress` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a MultiCastRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> multicastrange = NUMultiCastRange(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastRange') >>> multicastrange = NUMultiCastRange(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a MultiCastRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multicastrange = NUMultiCastRange(id=u'xxxx-xxx-xxx-xxx', name=u'MultiCastRange')
>>> multicastrange = NUMultiCastRange(data=my_dict)
"""
super(NUMultiCastRange, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._max_address = None
self._min_address = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_address", remote_name="maxAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="min_address", remote_name="minAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUMultiNICVPort
Represents a MultiNICVPort in the VSD
Notes: Encapsulates the Multi NIC VPort information for system monitoring entity.
class NUMultiNICVPort(NURESTObject):
""" Represents a MultiNICVPort in the VSD
Notes:
Encapsulates the Multi NIC VPort information for system monitoring entity.
"""
__rest_name__ = "multinicvport"
__resource_name__ = "multinicvports"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a MultiNICVPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multinicvport = NUMultiNICVPort(id=u'xxxx-xxx-xxx-xxx', name=u'MultiNICVPort')
>>> multinicvport = NUMultiNICVPort(data=my_dict)
"""
super(NUMultiNICVPort, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name for the Multi NIC VPort.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name for the Multi NIC VPort.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUMultiNICVPort
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name for the Multi NIC VPort.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var vports
Methods
def __init__(
self, **kwargs)
Initializes a MultiNICVPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> multinicvport = NUMultiNICVPort(id=u'xxxx-xxx-xxx-xxx', name=u'MultiNICVPort') >>> multinicvport = NUMultiNICVPort(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a MultiNICVPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> multinicvport = NUMultiNICVPort(id=u'xxxx-xxx-xxx-xxx', name=u'MultiNICVPort')
>>> multinicvport = NUMultiNICVPort(data=my_dict)
"""
super(NUMultiNICVPort, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNATMapEntry
Represents a NATMapEntry in the VSD
Notes: Defines a MAP between the private ip and public ip.
class NUNATMapEntry(NURESTObject):
""" Represents a NATMapEntry in the VSD
Notes:
Defines a MAP between the private ip and public ip.
"""
__rest_name__ = "natmapentry"
__resource_name__ = "natmapentries"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a NATMapEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> natmapentry = NUNATMapEntry(id=u'xxxx-xxx-xxx-xxx', name=u'NATMapEntry')
>>> natmapentry = NUNATMapEntry(data=my_dict)
"""
super(NUNATMapEntry, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._entity_scope = None
self._private_ip = None
self._associated_patnat_pool_id = None
self._public_ip = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="private_ip", remote_name="privateIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_patnat_pool_id", remote_name="associatedPATNATPoolID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_ip", remote_name="publicIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def private_ip(self):
""" Get private_ip value.
Notes:
Private IP address of the interface
This attribute is named `privateIP` in VSD API.
"""
return self._private_ip
@private_ip.setter
def private_ip(self, value):
""" Set private_ip value.
Notes:
Private IP address of the interface
This attribute is named `privateIP` in VSD API.
"""
self._private_ip = value
@property
def associated_patnat_pool_id(self):
""" Get associated_patnat_pool_id value.
Notes:
Indicates which PATNATPool this entry belongs to
This attribute is named `associatedPATNATPoolID` in VSD API.
"""
return self._associated_patnat_pool_id
@associated_patnat_pool_id.setter
def associated_patnat_pool_id(self, value):
""" Set associated_patnat_pool_id value.
Notes:
Indicates which PATNATPool this entry belongs to
This attribute is named `associatedPATNATPoolID` in VSD API.
"""
self._associated_patnat_pool_id = value
@property
def public_ip(self):
""" Get public_ip value.
Notes:
Public IP address of the interface
This attribute is named `publicIP` in VSD API.
"""
return self._public_ip
@public_ip.setter
def public_ip(self, value):
""" Set public_ip value.
Notes:
Public IP address of the interface
This attribute is named `publicIP` in VSD API.
"""
self._public_ip = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUNATMapEntry
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_patnat_pool_id
Get associated_patnat_pool_id value.
Notes: Indicates which PATNATPool this entry belongs to
This attribute is named `associatedPATNATPoolID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var private_ip
Get private_ip value.
Notes: Private IP address of the interface
This attribute is named `privateIP` in VSD API.
var public_ip
Get public_ip value.
Notes: Public IP address of the interface
This attribute is named `publicIP` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a NATMapEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> natmapentry = NUNATMapEntry(id=u'xxxx-xxx-xxx-xxx', name=u'NATMapEntry') >>> natmapentry = NUNATMapEntry(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NATMapEntry instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> natmapentry = NUNATMapEntry(id=u'xxxx-xxx-xxx-xxx', name=u'NATMapEntry')
>>> natmapentry = NUNATMapEntry(data=my_dict)
"""
super(NUNATMapEntry, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._entity_scope = None
self._private_ip = None
self._associated_patnat_pool_id = None
self._public_ip = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="private_ip", remote_name="privateIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_patnat_pool_id", remote_name="associatedPATNATPoolID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_ip", remote_name="publicIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNSGateway
Represents a NSGateway in the VSD
Notes: Represents Network Service Gateway object.
class NUNSGateway(NURESTObject):
""" Represents a NSGateway in the VSD
Notes:
Represents Network Service Gateway object.
"""
__rest_name__ = "nsgateway"
__resource_name__ = "nsgateways"
## Constants
CONST_CONFIGURATION_STATUS_FAILURE = "FAILURE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_BOOTSTRAP_STATUS_ACTIVE = "ACTIVE"
CONST_CONFIGURATION_RELOAD_STATE_PENDING = "PENDING"
CONST_PERSONALITY_OTHER = "OTHER"
CONST_BOOTSTRAP_STATUS_NOTIFICATION_APP_REQ_ACK = "NOTIFICATION_APP_REQ_ACK"
CONST_PERSONALITY_NSG = "NSG"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_CONFIGURATION_STATUS_SUCCESS = "SUCCESS"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_CONFIGURATION_RELOAD_STATE_UNKNOWN = "UNKNOWN"
CONST_PERSONALITY_DC7X50 = "DC7X50"
CONST_BOOTSTRAP_STATUS_CERTIFICATE_SIGNED = "CERTIFICATE_SIGNED"
CONST_BOOTSTRAP_STATUS_NOTIFICATION_APP_REQ_SENT = "NOTIFICATION_APP_REQ_SENT"
CONST_CONFIGURATION_STATUS_UNKNOWN = "UNKNOWN"
CONST_PERSONALITY_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_PERSONALITY_VSA = "VSA"
CONST_PERSONALITY_VSG = "VSG"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERSONALITY_VRSG = "VRSG"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_CONFIGURATION_RELOAD_STATE_APPLIED = "APPLIED"
CONST_CONFIGURATION_RELOAD_STATE_SENT = "SENT"
CONST_BOOTSTRAP_STATUS_INACTIVE = "INACTIVE"
def __init__(self, **kwargs):
""" Initializes a NSGateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsgateway = NUNSGateway(id=u'xxxx-xxx-xxx-xxx', name=u'NSGateway')
>>> nsgateway = NUNSGateway(data=my_dict)
"""
super(NUNSGateway, self).__init__()
# Read/Write Attributes
self._nat_traversal_enabled = None
self._name = None
self._last_updated_by = None
self._datapath_id = None
self._redundancy_group_id = None
self._template_id = None
self._pending = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._location_id = None
self._configuration_reload_state = None
self._configuration_status = None
self._bootstrap_id = None
self._bootstrap_status = None
self._associated_gateway_security_id = None
self._associated_gateway_security_profile_id = None
self._auto_disc_gateway_id = None
self._external_id = None
self._system_id = None
self.expose_attribute(local_name="nat_traversal_enabled", remote_name="NATTraversalEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_id", remote_name="datapathID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_group_id", remote_name="redundancyGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="pending", remote_name="pending", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="configuration_reload_state", remote_name="configurationReloadState", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'PENDING', u'SENT', u'UNKNOWN'])
self.expose_attribute(local_name="configuration_status", remote_name="configurationStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILURE', u'SUCCESS', u'UNKNOWN'])
self.expose_attribute(local_name="bootstrap_id", remote_name="bootstrapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bootstrap_status", remote_name="bootstrapStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACTIVE', u'CERTIFICATE_SIGNED', u'INACTIVE', u'NOTIFICATION_APP_REQ_ACK', u'NOTIFICATION_APP_REQ_SENT'])
self.expose_attribute(local_name="associated_gateway_security_id", remote_name="associatedGatewaySecurityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_gateway_security_profile_id", remote_name="associatedGatewaySecurityProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_disc_gateway_id", remote_name="autoDiscGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_id", remote_name="systemID", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.gateway_securities = NUGatewaySecuritiesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.gateway_security_profiles = NUGatewaySecurityProfilesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.patnat_pools = NUPATNATPoolsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.infrastructure_configs = NUInfrastructureConfigsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.locations = NULocationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bootstraps = NUBootstrapsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bootstrap_activations = NUBootstrapActivationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_ports = NUNSPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def nat_traversal_enabled(self):
""" Get nat_traversal_enabled value.
Notes:
Boolean value that states if the NSG instance is in a network that is behind a NAT device and will use NAT Traversal procedures to talk to other NSGs and the Internet.
This attribute is named `NATTraversalEnabled` in VSD API.
"""
return self._nat_traversal_enabled
@nat_traversal_enabled.setter
def nat_traversal_enabled(self, value):
""" Set nat_traversal_enabled value.
Notes:
Boolean value that states if the NSG instance is in a network that is behind a NAT device and will use NAT Traversal procedures to talk to other NSGs and the Internet.
This attribute is named `NATTraversalEnabled` in VSD API.
"""
self._nat_traversal_enabled = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Gateway
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Gateway
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def datapath_id(self):
""" Get datapath_id value.
Notes:
Identifier of the Gateway, based on the systemId
This attribute is named `datapathID` in VSD API.
"""
return self._datapath_id
@datapath_id.setter
def datapath_id(self, value):
""" Set datapath_id value.
Notes:
Identifier of the Gateway, based on the systemId
This attribute is named `datapathID` in VSD API.
"""
self._datapath_id = value
@property
def redundancy_group_id(self):
""" Get redundancy_group_id value.
Notes:
The Redundancy Gateway Group associated with this Gateway Instance. This is a read only attribute
This attribute is named `redundancyGroupID` in VSD API.
"""
return self._redundancy_group_id
@redundancy_group_id.setter
def redundancy_group_id(self, value):
""" Set redundancy_group_id value.
Notes:
The Redundancy Gateway Group associated with this Gateway Instance. This is a read only attribute
This attribute is named `redundancyGroupID` in VSD API.
"""
self._redundancy_group_id = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the template that this Gateway was created from. This should be set when instantiating a Gateway
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the template that this Gateway was created from. This should be set when instantiating a Gateway
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def pending(self):
""" Get pending value.
Notes:
Indicates that this gateway is pending state or state. When in pending state it cannot be modified from REST.
"""
return self._pending
@pending.setter
def pending(self, value):
""" Set pending value.
Notes:
Indicates that this gateway is pending state or state. When in pending state it cannot be modified from REST.
"""
self._pending = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def personality(self):
""" Get personality value.
Notes:
Personality of the Gateway - NSG, cannot be changed after creation.
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
Personality of the Gateway - NSG, cannot be changed after creation.
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Gateway
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Gateway
"""
self._description = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location_id(self):
""" Get location_id value.
Notes:
The NSGateway's Location. NOTE: this is a read only property, it can only be set through the location object
This attribute is named `locationID` in VSD API.
"""
return self._location_id
@location_id.setter
def location_id(self, value):
""" Set location_id value.
Notes:
The NSGateway's Location. NOTE: this is a read only property, it can only be set through the location object
This attribute is named `locationID` in VSD API.
"""
self._location_id = value
@property
def configuration_reload_state(self):
""" Get configuration_reload_state value.
Notes:
This attribute is named `configurationReloadState` in VSD API.
"""
return self._configuration_reload_state
@configuration_reload_state.setter
def configuration_reload_state(self, value):
""" Set configuration_reload_state value.
Notes:
This attribute is named `configurationReloadState` in VSD API.
"""
self._configuration_reload_state = value
@property
def configuration_status(self):
""" Get configuration_status value.
Notes:
This attribute is named `configurationStatus` in VSD API.
"""
return self._configuration_status
@configuration_status.setter
def configuration_status(self, value):
""" Set configuration_status value.
Notes:
This attribute is named `configurationStatus` in VSD API.
"""
self._configuration_status = value
@property
def bootstrap_id(self):
""" Get bootstrap_id value.
Notes:
The bootstrap details associated with this NSGateway. NOTE: this is a read only property, it can only be set during creation of an NSG
This attribute is named `bootstrapID` in VSD API.
"""
return self._bootstrap_id
@bootstrap_id.setter
def bootstrap_id(self, value):
""" Set bootstrap_id value.
Notes:
The bootstrap details associated with this NSGateway. NOTE: this is a read only property, it can only be set during creation of an NSG
This attribute is named `bootstrapID` in VSD API.
"""
self._bootstrap_id = value
@property
def bootstrap_status(self):
""" Get bootstrap_status value.
Notes:
The bootstrap status of this NSGateway. NOTE: this is a read only property
This attribute is named `bootstrapStatus` in VSD API.
"""
return self._bootstrap_status
@bootstrap_status.setter
def bootstrap_status(self, value):
""" Set bootstrap_status value.
Notes:
The bootstrap status of this NSGateway. NOTE: this is a read only property
This attribute is named `bootstrapStatus` in VSD API.
"""
self._bootstrap_status = value
@property
def associated_gateway_security_id(self):
""" Get associated_gateway_security_id value.
Notes:
Readonly Id of the associated gateway security object
This attribute is named `associatedGatewaySecurityID` in VSD API.
"""
return self._associated_gateway_security_id
@associated_gateway_security_id.setter
def associated_gateway_security_id(self, value):
""" Set associated_gateway_security_id value.
Notes:
Readonly Id of the associated gateway security object
This attribute is named `associatedGatewaySecurityID` in VSD API.
"""
self._associated_gateway_security_id = value
@property
def associated_gateway_security_profile_id(self):
""" Get associated_gateway_security_profile_id value.
Notes:
Readonly Id of the associated gateway security profile object
This attribute is named `associatedGatewaySecurityProfileID` in VSD API.
"""
return self._associated_gateway_security_profile_id
@associated_gateway_security_profile_id.setter
def associated_gateway_security_profile_id(self, value):
""" Set associated_gateway_security_profile_id value.
Notes:
Readonly Id of the associated gateway security profile object
This attribute is named `associatedGatewaySecurityProfileID` in VSD API.
"""
self._associated_gateway_security_profile_id = value
@property
def auto_disc_gateway_id(self):
""" Get auto_disc_gateway_id value.
Notes:
The Auto Discovered Gateway associated with this Gateway Instance
This attribute is named `autoDiscGatewayID` in VSD API.
"""
return self._auto_disc_gateway_id
@auto_disc_gateway_id.setter
def auto_disc_gateway_id(self, value):
""" Set auto_disc_gateway_id value.
Notes:
The Auto Discovered Gateway associated with this Gateway Instance
This attribute is named `autoDiscGatewayID` in VSD API.
"""
self._auto_disc_gateway_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def system_id(self):
""" Get system_id value.
Notes:
Identifier of the Gateway, cannot be modified after creation
This attribute is named `systemID` in VSD API.
"""
return self._system_id
@system_id.setter
def system_id(self, value):
""" Set system_id value.
Notes:
Identifier of the Gateway, cannot be modified after creation
This attribute is named `systemID` in VSD API.
"""
self._system_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUNSGateway
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_BOOTSTRAP_STATUS_ACTIVE
var CONST_BOOTSTRAP_STATUS_CERTIFICATE_SIGNED
var CONST_BOOTSTRAP_STATUS_INACTIVE
var CONST_BOOTSTRAP_STATUS_NOTIFICATION_APP_REQ_ACK
var CONST_BOOTSTRAP_STATUS_NOTIFICATION_APP_REQ_SENT
var CONST_CONFIGURATION_RELOAD_STATE_APPLIED
var CONST_CONFIGURATION_RELOAD_STATE_PENDING
var CONST_CONFIGURATION_RELOAD_STATE_SENT
var CONST_CONFIGURATION_RELOAD_STATE_UNKNOWN
var CONST_CONFIGURATION_STATUS_FAILURE
var CONST_CONFIGURATION_STATUS_SUCCESS
var CONST_CONFIGURATION_STATUS_UNKNOWN
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PERSONALITY_DC7X50
var CONST_PERSONALITY_HARDWARE_VTEP
var CONST_PERSONALITY_NSG
var CONST_PERSONALITY_OTHER
var CONST_PERSONALITY_VRSG
var CONST_PERSONALITY_VSA
var CONST_PERSONALITY_VSG
var resource_name
var rest_name
Instance variables
var alarms
var associated_gateway_security_id
Get associated_gateway_security_id value.
Notes: Readonly Id of the associated gateway security object
This attribute is named `associatedGatewaySecurityID` in VSD API.
var associated_gateway_security_profile_id
Get associated_gateway_security_profile_id value.
Notes: Readonly Id of the associated gateway security profile object
This attribute is named `associatedGatewaySecurityProfileID` in VSD API.
var auto_disc_gateway_id
Get auto_disc_gateway_id value.
Notes: The Auto Discovered Gateway associated with this Gateway Instance
This attribute is named `autoDiscGatewayID` in VSD API.
var bootstrap_activations
var bootstrap_id
Get bootstrap_id value.
Notes: The bootstrap details associated with this NSGateway. NOTE: this is a read only property, it can only be set during creation of an NSG
This attribute is named `bootstrapID` in VSD API.
var bootstrap_status
Get bootstrap_status value.
Notes: The bootstrap status of this NSGateway. NOTE: this is a read only property
This attribute is named `bootstrapStatus` in VSD API.
var bootstraps
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var configuration_reload_state
Get configuration_reload_state value.
Notes:
This attribute is named `configurationReloadState` in VSD API.
var configuration_status
Get configuration_status value.
Notes:
This attribute is named `configurationStatus` in VSD API.
var creation_date
Get creation date
var datapath_id
Get datapath_id value.
Notes: Identifier of the Gateway, based on the systemId
This attribute is named `datapathID` in VSD API.
var description
Get description value.
Notes: A description of the Gateway
var enterprise_id
Get enterprise_id value.
Notes: The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_securities
var gateway_security_profiles
var global_metadatas
var id
Get object id
var infrastructure_configs
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location_id
Get location_id value.
Notes: The NSGateway's Location. NOTE: this is a read only property, it can only be set through the location object
This attribute is named `locationID` in VSD API.
var locations
var metadatas
var name
Get name value.
Notes: Name of the Gateway
var nat_traversal_enabled
Get nat_traversal_enabled value.
Notes: Boolean value that states if the NSG instance is in a network that is behind a NAT device and will use NAT Traversal procedures to talk to other NSGs and the Internet.
This attribute is named `NATTraversalEnabled` in VSD API.
var ns_ports
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var patnat_pools
var pending
Get pending value.
Notes: Indicates that this gateway is pending state or state. When in pending state it cannot be modified from REST.
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var personality
Get personality value.
Notes: Personality of the Gateway - NSG, cannot be changed after creation.
var redundancy_group_id
Get redundancy_group_id value.
Notes: The Redundancy Gateway Group associated with this Gateway Instance. This is a read only attribute
This attribute is named `redundancyGroupID` in VSD API.
var system_id
Get system_id value.
Notes: Identifier of the Gateway, cannot be modified after creation
This attribute is named `systemID` in VSD API.
var template_id
Get template_id value.
Notes: The ID of the template that this Gateway was created from. This should be set when instantiating a Gateway
This attribute is named `templateID` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a NSGateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> nsgateway = NUNSGateway(id=u'xxxx-xxx-xxx-xxx', name=u'NSGateway') >>> nsgateway = NUNSGateway(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NSGateway instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsgateway = NUNSGateway(id=u'xxxx-xxx-xxx-xxx', name=u'NSGateway')
>>> nsgateway = NUNSGateway(data=my_dict)
"""
super(NUNSGateway, self).__init__()
# Read/Write Attributes
self._nat_traversal_enabled = None
self._name = None
self._last_updated_by = None
self._datapath_id = None
self._redundancy_group_id = None
self._template_id = None
self._pending = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._location_id = None
self._configuration_reload_state = None
self._configuration_status = None
self._bootstrap_id = None
self._bootstrap_status = None
self._associated_gateway_security_id = None
self._associated_gateway_security_profile_id = None
self._auto_disc_gateway_id = None
self._external_id = None
self._system_id = None
self.expose_attribute(local_name="nat_traversal_enabled", remote_name="NATTraversalEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_id", remote_name="datapathID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_group_id", remote_name="redundancyGroupID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="pending", remote_name="pending", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location_id", remote_name="locationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="configuration_reload_state", remote_name="configurationReloadState", attribute_type=str, is_required=False, is_unique=False, choices=[u'APPLIED', u'PENDING', u'SENT', u'UNKNOWN'])
self.expose_attribute(local_name="configuration_status", remote_name="configurationStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILURE', u'SUCCESS', u'UNKNOWN'])
self.expose_attribute(local_name="bootstrap_id", remote_name="bootstrapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bootstrap_status", remote_name="bootstrapStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACTIVE', u'CERTIFICATE_SIGNED', u'INACTIVE', u'NOTIFICATION_APP_REQ_ACK', u'NOTIFICATION_APP_REQ_SENT'])
self.expose_attribute(local_name="associated_gateway_security_id", remote_name="associatedGatewaySecurityID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_gateway_security_profile_id", remote_name="associatedGatewaySecurityProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_disc_gateway_id", remote_name="autoDiscGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="system_id", remote_name="systemID", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.gateway_securities = NUGatewaySecuritiesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.gateway_security_profiles = NUGatewaySecurityProfilesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.patnat_pools = NUPATNATPoolsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.infrastructure_configs = NUInfrastructureConfigsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.locations = NULocationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bootstraps = NUBootstrapsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bootstrap_activations = NUBootstrapActivationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_ports = NUNSPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNSGatewayTemplate
Represents a NSGatewayTemplate in the VSD
Notes: Represents a Network Service Gateway Template.
class NUNSGatewayTemplate(NURESTObject):
""" Represents a NSGatewayTemplate in the VSD
Notes:
Represents a Network Service Gateway Template.
"""
__rest_name__ = "nsgatewaytemplate"
__resource_name__ = "nsgatewaytemplates"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a NSGatewayTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsgatewaytemplate = NUNSGatewayTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'NSGatewayTemplate')
>>> nsgatewaytemplate = NUNSGatewayTemplate(data=my_dict)
"""
super(NUNSGatewayTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._infrastructure_profile_id = None
self._enterprise_id = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_port_templates = NUNSPortTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Gateway
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Gateway
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Gateway
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Gateway
"""
self._description = value
@property
def infrastructure_profile_id(self):
""" Get infrastructure_profile_id value.
Notes:
The ID of the infrastructure gateway profile this instance of a Gateway is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
return self._infrastructure_profile_id
@infrastructure_profile_id.setter
def infrastructure_profile_id(self, value):
""" Set infrastructure_profile_id value.
Notes:
The ID of the infrastructure gateway profile this instance of a Gateway is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
self._infrastructure_profile_id = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUNSGatewayTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Gateway
var enterprise_id
Get enterprise_id value.
Notes: The enterprise associated with this Gateway. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var infrastructure_profile_id
Get infrastructure_profile_id value.
Notes: The ID of the infrastructure gateway profile this instance of a Gateway is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Gateway
var ns_port_templates
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a NSGatewayTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> nsgatewaytemplate = NUNSGatewayTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'NSGatewayTemplate') >>> nsgatewaytemplate = NUNSGatewayTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NSGatewayTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsgatewaytemplate = NUNSGatewayTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'NSGatewayTemplate')
>>> nsgatewaytemplate = NUNSGatewayTemplate(data=my_dict)
"""
super(NUNSGatewayTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._infrastructure_profile_id = None
self._enterprise_id = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_port_templates = NUNSPortTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNSPort
Represents a NSPort in the VSD
Notes: Represents a Port of a particular NS gateway object.
class NUNSPort(NURESTObject):
""" Represents a NSPort in the VSD
Notes:
Represents a Port of a particular NS gateway object.
"""
__rest_name__ = "nsport"
__resource_name__ = "nsports"
## Constants
CONST_PORT_TYPE_NETWORK = "NETWORK"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_STATUS_READY = "READY"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_STATUS_INITIALIZED = "INITIALIZED"
CONST_STATUS_MISMATCH = "MISMATCH"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PORT_TYPE_ACCESS = "ACCESS"
CONST_STATUS_ORPHAN = "ORPHAN"
def __init__(self, **kwargs):
""" Initializes a NSPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsport = NUNSPort(id=u'xxxx-xxx-xxx-xxx', name=u'NSPort')
>>> nsport = NUNSPort(data=my_dict)
"""
super(NUNSPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._template_id = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._infrastructure_profile_id = None
self._entity_scope = None
self._port_type = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._associated_redundant_port_id = None
self._associated_vsc_profile_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_redundant_port_id", remote_name="associatedRedundantPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vsc_profile_id", remote_name="associatedVSCProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_port_static_configurations = NUNSPortStaticConfigurationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vlan_range(self):
""" Get vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
return self._vlan_range
@vlan_range.setter
def vlan_range(self, value):
""" Set vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
self._vlan_range = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Port
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Port
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def physical_name(self):
""" Get physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
return self._physical_name
@physical_name.setter
def physical_name(self, value):
""" Set physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
self._physical_name = value
@property
def infrastructure_profile_id(self):
""" Get infrastructure_profile_id value.
Notes:
The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
return self._infrastructure_profile_id
@infrastructure_profile_id.setter
def infrastructure_profile_id(self, value):
""" Set infrastructure_profile_id value.
Notes:
The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
self._infrastructure_profile_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port_type(self):
""" Get port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
return self._port_type
@port_type.setter
def port_type(self, value):
""" Set port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
self._port_type = value
@property
def use_user_mnemonic(self):
""" Get use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
return self._use_user_mnemonic
@use_user_mnemonic.setter
def use_user_mnemonic(self, value):
""" Set use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
self._use_user_mnemonic = value
@property
def user_mnemonic(self):
""" Get user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
return self._user_mnemonic
@user_mnemonic.setter
def user_mnemonic(self, value):
""" Set user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
self._user_mnemonic = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def associated_redundant_port_id(self):
""" Get associated_redundant_port_id value.
Notes:
ID of the redundant port to which the Port is associated to.
This attribute is named `associatedRedundantPortID` in VSD API.
"""
return self._associated_redundant_port_id
@associated_redundant_port_id.setter
def associated_redundant_port_id(self, value):
""" Set associated_redundant_port_id value.
Notes:
ID of the redundant port to which the Port is associated to.
This attribute is named `associatedRedundantPortID` in VSD API.
"""
self._associated_redundant_port_id = value
@property
def associated_vsc_profile_id(self):
""" Get associated_vsc_profile_id value.
Notes:
The ID of the infrastructure VSC profile this is associated with this instance of a port or port template.
This attribute is named `associatedVSCProfileID` in VSD API.
"""
return self._associated_vsc_profile_id
@associated_vsc_profile_id.setter
def associated_vsc_profile_id(self, value):
""" Set associated_vsc_profile_id value.
Notes:
The ID of the infrastructure VSC profile this is associated with this instance of a port or port template.
This attribute is named `associatedVSCProfileID` in VSD API.
"""
self._associated_vsc_profile_id = value
@property
def status(self):
""" Get status value.
Notes:
Status of the port.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Status of the port.
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUNSPort
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PORT_TYPE_ACCESS
var CONST_PORT_TYPE_NETWORK
var CONST_STATUS_INITIALIZED
var CONST_STATUS_MISMATCH
var CONST_STATUS_ORPHAN
var CONST_STATUS_READY
var resource_name
var rest_name
Instance variables
var alarms
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var associated_redundant_port_id
Get associated_redundant_port_id value.
Notes: ID of the redundant port to which the Port is associated to.
This attribute is named `associatedRedundantPortID` in VSD API.
var associated_vsc_profile_id
Get associated_vsc_profile_id value.
Notes: The ID of the infrastructure VSC profile this is associated with this instance of a port or port template.
This attribute is named `associatedVSCProfileID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var infrastructure_profile_id
Get infrastructure_profile_id value.
Notes: The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Port
var ns_port_static_configurations
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var physical_name
Get physical_name value.
Notes: Identifier of the Port
This attribute is named `physicalName` in VSD API.
var port_type
Get port_type value.
Notes: Type of the Port.
This attribute is named `portType` in VSD API.
var statistics
var statistics_policies
var status
Get status value.
Notes: Status of the port.
var template_id
Get template_id value.
Notes: The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
var use_user_mnemonic
Get use_user_mnemonic value.
Notes: determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
var user_mnemonic
Get user_mnemonic value.
Notes: user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
var vlan_range
Get vlan_range value.
Notes: VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
var vlans
Methods
def __init__(
self, **kwargs)
Initializes a NSPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> nsport = NUNSPort(id=u'xxxx-xxx-xxx-xxx', name=u'NSPort') >>> nsport = NUNSPort(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NSPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsport = NUNSPort(id=u'xxxx-xxx-xxx-xxx', name=u'NSPort')
>>> nsport = NUNSPort(data=my_dict)
"""
super(NUNSPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._template_id = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._infrastructure_profile_id = None
self._entity_scope = None
self._port_type = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._associated_redundant_port_id = None
self._associated_vsc_profile_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_redundant_port_id", remote_name="associatedRedundantPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vsc_profile_id", remote_name="associatedVSCProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_port_static_configurations = NUNSPortStaticConfigurationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNSPortStaticConfiguration
Represents a NSPortStaticConfiguration in the VSD
Notes: Represents a network port static configuration in the context of an Network Services Gateway.
class NUNSPortStaticConfiguration(NURESTObject):
""" Represents a NSPortStaticConfiguration in the VSD
Notes:
Represents a network port static configuration in the context of an Network Services Gateway.
"""
__rest_name__ = "nsportstaticconfiguration"
__resource_name__ = "nsportstaticconfigurations"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a NSPortStaticConfiguration instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsportstaticconfiguration = NUNSPortStaticConfiguration(id=u'xxxx-xxx-xxx-xxx', name=u'NSPortStaticConfiguration')
>>> nsportstaticconfiguration = NUNSPortStaticConfiguration(data=my_dict)
"""
super(NUNSPortStaticConfiguration, self).__init__()
# Read/Write Attributes
self._dns_address = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._netmask = None
self._enabled = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="dns_address", remote_name="DNSAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enabled", remote_name="enabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def dns_address(self):
""" Get dns_address value.
Notes:
DNS Address for Network NSPort.
This attribute is named `DNSAddress` in VSD API.
"""
return self._dns_address
@dns_address.setter
def dns_address(self, value):
""" Set dns_address value.
Notes:
DNS Address for Network NSPort.
This attribute is named `DNSAddress` in VSD API.
"""
self._dns_address = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
IP address of the gateway bound to the Network NSPort.
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
IP address of the gateway bound to the Network NSPort.
"""
self._gateway = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the Network NSPort.
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the Network NSPort.
"""
self._address = value
@property
def netmask(self):
""" Get netmask value.
Notes:
IP address netmask of the Network NSPort.
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
IP address netmask of the Network NSPort.
"""
self._netmask = value
@property
def enabled(self):
""" Get enabled value.
Notes:
Boolean value that states if the NSG Port static configuration needs to be applied.
"""
return self._enabled
@enabled.setter
def enabled(self, value):
""" Set enabled value.
Notes:
Boolean value that states if the NSG Port static configuration needs to be applied.
"""
self._enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUNSPortStaticConfiguration
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the Network NSPort.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var dns_address
Get dns_address value.
Notes: DNS Address for Network NSPort.
This attribute is named `DNSAddress` in VSD API.
var enabled
Get enabled value.
Notes: Boolean value that states if the NSG Port static configuration needs to be applied.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: IP address of the gateway bound to the Network NSPort.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var netmask
Get netmask value.
Notes: IP address netmask of the Network NSPort.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a NSPortStaticConfiguration instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> nsportstaticconfiguration = NUNSPortStaticConfiguration(id=u'xxxx-xxx-xxx-xxx', name=u'NSPortStaticConfiguration') >>> nsportstaticconfiguration = NUNSPortStaticConfiguration(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NSPortStaticConfiguration instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsportstaticconfiguration = NUNSPortStaticConfiguration(id=u'xxxx-xxx-xxx-xxx', name=u'NSPortStaticConfiguration')
>>> nsportstaticconfiguration = NUNSPortStaticConfiguration(data=my_dict)
"""
super(NUNSPortStaticConfiguration, self).__init__()
# Read/Write Attributes
self._dns_address = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._netmask = None
self._enabled = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="dns_address", remote_name="DNSAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enabled", remote_name="enabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNSPortTemplate
Represents a NSPortTemplate in the VSD
Notes: Represents Port Template object under a given gateway template object.
class NUNSPortTemplate(NURESTObject):
""" Represents a NSPortTemplate in the VSD
Notes:
Represents Port Template object under a given gateway template object.
"""
__rest_name__ = "nsporttemplate"
__resource_name__ = "nsporttemplates"
## Constants
CONST_PORT_TYPE_NETWORK = "NETWORK"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PORT_TYPE_ACCESS = "ACCESS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a NSPortTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsporttemplate = NUNSPortTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'NSPortTemplate')
>>> nsporttemplate = NUNSPortTemplate(data=my_dict)
"""
super(NUNSPortTemplate, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._description = None
self._physical_name = None
self._infrastructure_profile_id = None
self._entity_scope = None
self._port_type = None
self._associated_egress_qos_policy_id = None
self._associated_vsc_profile_id = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vsc_profile_id", remote_name="associatedVSCProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlan_templates = NUVLANTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vlan_range(self):
""" Get vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
return self._vlan_range
@vlan_range.setter
def vlan_range(self, value):
""" Set vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
self._vlan_range = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Port
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Port
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def physical_name(self):
""" Get physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
return self._physical_name
@physical_name.setter
def physical_name(self, value):
""" Set physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
self._physical_name = value
@property
def infrastructure_profile_id(self):
""" Get infrastructure_profile_id value.
Notes:
The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
return self._infrastructure_profile_id
@infrastructure_profile_id.setter
def infrastructure_profile_id(self, value):
""" Set infrastructure_profile_id value.
Notes:
The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
self._infrastructure_profile_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port_type(self):
""" Get port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
return self._port_type
@port_type.setter
def port_type(self, value):
""" Set port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
self._port_type = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def associated_vsc_profile_id(self):
""" Get associated_vsc_profile_id value.
Notes:
The ID of the infrastructure VSC profile this is associated with this instance of a port or port template.
This attribute is named `associatedVSCProfileID` in VSD API.
"""
return self._associated_vsc_profile_id
@associated_vsc_profile_id.setter
def associated_vsc_profile_id(self, value):
""" Set associated_vsc_profile_id value.
Notes:
The ID of the infrastructure VSC profile this is associated with this instance of a port or port template.
This attribute is named `associatedVSCProfileID` in VSD API.
"""
self._associated_vsc_profile_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUNSPortTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PORT_TYPE_ACCESS
var CONST_PORT_TYPE_NETWORK
var resource_name
var rest_name
Instance variables
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var associated_vsc_profile_id
Get associated_vsc_profile_id value.
Notes: The ID of the infrastructure VSC profile this is associated with this instance of a port or port template.
This attribute is named `associatedVSCProfileID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var infrastructure_profile_id
Get infrastructure_profile_id value.
Notes: The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Port
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var physical_name
Get physical_name value.
Notes: Identifier of the Port
This attribute is named `physicalName` in VSD API.
var port_type
Get port_type value.
Notes: Type of the Port.
This attribute is named `portType` in VSD API.
var vlan_range
Get vlan_range value.
Notes: VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
var vlan_templates
Methods
def __init__(
self, **kwargs)
Initializes a NSPortTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> nsporttemplate = NUNSPortTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'NSPortTemplate') >>> nsporttemplate = NUNSPortTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NSPortTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsporttemplate = NUNSPortTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'NSPortTemplate')
>>> nsporttemplate = NUNSPortTemplate(data=my_dict)
"""
super(NUNSPortTemplate, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._description = None
self._physical_name = None
self._infrastructure_profile_id = None
self._entity_scope = None
self._port_type = None
self._associated_egress_qos_policy_id = None
self._associated_vsc_profile_id = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vsc_profile_id", remote_name="associatedVSCProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlan_templates = NUVLANTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNSRedundantGatewayGroup
Represents a NSRedundantGatewayGroup in the VSD
Notes: Represents Redundant Group formed by two VNS Gateways.
class NUNSRedundantGatewayGroup(NURESTObject):
""" Represents a NSRedundantGatewayGroup in the VSD
Notes:
Represents Redundant Group formed by two VNS Gateways.
"""
__rest_name__ = "nsgredundancygroup"
__resource_name__ = "nsgredundancygroups"
## Constants
CONST_PERSONALITY_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_PERSONALITY_VSA = "VSA"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERSONALITY_VSG = "VSG"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_PERSONALITY_OTHER = "OTHER"
CONST_PERSONALITY_NSG = "NSG"
CONST_REDUNDANT_GATEWAY_STATUS_SUCCESS = "SUCCESS"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERSONALITY_VRSG = "VRSG"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_PERSONALITY_DC7X50 = "DC7X50"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_REDUNDANT_GATEWAY_STATUS_FAILED = "FAILED"
def __init__(self, **kwargs):
""" Initializes a NSRedundantGatewayGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsredundantgatewaygroup = NUNSRedundantGatewayGroup(id=u'xxxx-xxx-xxx-xxx', name=u'NSRedundantGatewayGroup')
>>> nsredundantgatewaygroup = NUNSRedundantGatewayGroup(data=my_dict)
"""
super(NUNSRedundantGatewayGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway_peer1_autodiscovered_gateway_id = None
self._gateway_peer1_id = None
self._gateway_peer1_name = None
self._gateway_peer2_autodiscovered_gateway_id = None
self._gateway_peer2_name = None
self._heartbeat_interval = None
self._heartbeat_vlanid = None
self._redundancy_port_ids = None
self._redundant_gateway_status = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._consecutive_failures_count = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_autodiscovered_gateway_id", remote_name="gatewayPeer1AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_id", remote_name="gatewayPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_name", remote_name="gatewayPeer1Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_autodiscovered_gateway_id", remote_name="gatewayPeer2AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_name", remote_name="gatewayPeer2Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="heartbeat_interval", remote_name="heartbeatInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="heartbeat_vlanid", remote_name="heartbeatVLANID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_port_ids", remote_name="redundancyPortIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundant_gateway_status", remote_name="redundantGatewayStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILED', u'SUCCESS'])
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="consecutive_failures_count", remote_name="consecutiveFailuresCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_gateways = NUNSGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redundant_ports = NURedundantPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Redundancy Group
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Redundancy Group
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_peer1_autodiscovered_gateway_id(self):
""" Get gateway_peer1_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway configuration owner in this Redundant Group.
This attribute is named `gatewayPeer1AutodiscoveredGatewayID` in VSD API.
"""
return self._gateway_peer1_autodiscovered_gateway_id
@gateway_peer1_autodiscovered_gateway_id.setter
def gateway_peer1_autodiscovered_gateway_id(self, value):
""" Set gateway_peer1_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway configuration owner in this Redundant Group.
This attribute is named `gatewayPeer1AutodiscoveredGatewayID` in VSD API.
"""
self._gateway_peer1_autodiscovered_gateway_id = value
@property
def gateway_peer1_id(self):
""" Get gateway_peer1_id value.
Notes:
The gateway configuration owner in this Redundant Group. when Redundant Group is deleted this gateway will recieve vport associations
This attribute is named `gatewayPeer1ID` in VSD API.
"""
return self._gateway_peer1_id
@gateway_peer1_id.setter
def gateway_peer1_id(self, value):
""" Set gateway_peer1_id value.
Notes:
The gateway configuration owner in this Redundant Group. when Redundant Group is deleted this gateway will recieve vport associations
This attribute is named `gatewayPeer1ID` in VSD API.
"""
self._gateway_peer1_id = value
@property
def gateway_peer1_name(self):
""" Get gateway_peer1_name value.
Notes:
The gateway configuration owner name in this Redundant Group
This attribute is named `gatewayPeer1Name` in VSD API.
"""
return self._gateway_peer1_name
@gateway_peer1_name.setter
def gateway_peer1_name(self, value):
""" Set gateway_peer1_name value.
Notes:
The gateway configuration owner name in this Redundant Group
This attribute is named `gatewayPeer1Name` in VSD API.
"""
self._gateway_peer1_name = value
@property
def gateway_peer2_autodiscovered_gateway_id(self):
""" Get gateway_peer2_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway peer in this Redundant Group
This attribute is named `gatewayPeer2AutodiscoveredGatewayID` in VSD API.
"""
return self._gateway_peer2_autodiscovered_gateway_id
@gateway_peer2_autodiscovered_gateway_id.setter
def gateway_peer2_autodiscovered_gateway_id(self, value):
""" Set gateway_peer2_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway peer in this Redundant Group
This attribute is named `gatewayPeer2AutodiscoveredGatewayID` in VSD API.
"""
self._gateway_peer2_autodiscovered_gateway_id = value
@property
def gateway_peer2_name(self):
""" Get gateway_peer2_name value.
Notes:
The gateway peer name in this Redundant Group
This attribute is named `gatewayPeer2Name` in VSD API.
"""
return self._gateway_peer2_name
@gateway_peer2_name.setter
def gateway_peer2_name(self, value):
""" Set gateway_peer2_name value.
Notes:
The gateway peer name in this Redundant Group
This attribute is named `gatewayPeer2Name` in VSD API.
"""
self._gateway_peer2_name = value
@property
def heartbeat_interval(self):
""" Get heartbeat_interval value.
Notes:
Heartbeat interval in milliseconds to declare the neighbor dead.
This attribute is named `heartbeatInterval` in VSD API.
"""
return self._heartbeat_interval
@heartbeat_interval.setter
def heartbeat_interval(self, value):
""" Set heartbeat_interval value.
Notes:
Heartbeat interval in milliseconds to declare the neighbor dead.
This attribute is named `heartbeatInterval` in VSD API.
"""
self._heartbeat_interval = value
@property
def heartbeat_vlanid(self):
""" Get heartbeat_vlanid value.
Notes:
Heartbeat VLAN used for BFD.
This attribute is named `heartbeatVLANID` in VSD API.
"""
return self._heartbeat_vlanid
@heartbeat_vlanid.setter
def heartbeat_vlanid(self, value):
""" Set heartbeat_vlanid value.
Notes:
Heartbeat VLAN used for BFD.
This attribute is named `heartbeatVLANID` in VSD API.
"""
self._heartbeat_vlanid = value
@property
def redundancy_port_ids(self):
""" Get redundancy_port_ids value.
Notes:
Collections resilient port ids associated with this redundant group.
This attribute is named `redundancyPortIDs` in VSD API.
"""
return self._redundancy_port_ids
@redundancy_port_ids.setter
def redundancy_port_ids(self, value):
""" Set redundancy_port_ids value.
Notes:
Collections resilient port ids associated with this redundant group.
This attribute is named `redundancyPortIDs` in VSD API.
"""
self._redundancy_port_ids = value
@property
def redundant_gateway_status(self):
""" Get redundant_gateway_status value.
Notes:
The status of Redundant Group.
This attribute is named `redundantGatewayStatus` in VSD API.
"""
return self._redundant_gateway_status
@redundant_gateway_status.setter
def redundant_gateway_status(self, value):
""" Set redundant_gateway_status value.
Notes:
The status of Redundant Group.
This attribute is named `redundantGatewayStatus` in VSD API.
"""
self._redundant_gateway_status = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def personality(self):
""" Get personality value.
Notes:
Derived personality of the Redundancy Group.
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
Derived personality of the Redundancy Group.
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Redundancy Group
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Redundancy Group
"""
self._description = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
The enterprise associated with this Redundant Group. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
The enterprise associated with this Redundant Group. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def consecutive_failures_count(self):
""" Get consecutive_failures_count value.
Notes:
Consecutive failure count.
This attribute is named `consecutiveFailuresCount` in VSD API.
"""
return self._consecutive_failures_count
@consecutive_failures_count.setter
def consecutive_failures_count(self, value):
""" Set consecutive_failures_count value.
Notes:
Consecutive failure count.
This attribute is named `consecutiveFailuresCount` in VSD API.
"""
self._consecutive_failures_count = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUNSRedundantGatewayGroup
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PERSONALITY_DC7X50
var CONST_PERSONALITY_HARDWARE_VTEP
var CONST_PERSONALITY_NSG
var CONST_PERSONALITY_OTHER
var CONST_PERSONALITY_VRSG
var CONST_PERSONALITY_VSA
var CONST_PERSONALITY_VSG
var CONST_REDUNDANT_GATEWAY_STATUS_FAILED
var CONST_REDUNDANT_GATEWAY_STATUS_SUCCESS
var resource_name
var rest_name
Instance variables
var alarms
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var consecutive_failures_count
Get consecutive_failures_count value.
Notes: Consecutive failure count.
This attribute is named `consecutiveFailuresCount` in VSD API.
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the Redundancy Group
var enterprise_id
Get enterprise_id value.
Notes: The enterprise associated with this Redundant Group. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_peer1_autodiscovered_gateway_id
Get gateway_peer1_autodiscovered_gateway_id value.
Notes: The Auto Discovered Gateway configuration owner in this Redundant Group.
This attribute is named `gatewayPeer1AutodiscoveredGatewayID` in VSD API.
var gateway_peer1_id
Get gateway_peer1_id value.
Notes: The gateway configuration owner in this Redundant Group. when Redundant Group is deleted this gateway will recieve vport associations
This attribute is named `gatewayPeer1ID` in VSD API.
var gateway_peer1_name
Get gateway_peer1_name value.
Notes: The gateway configuration owner name in this Redundant Group
This attribute is named `gatewayPeer1Name` in VSD API.
var gateway_peer2_autodiscovered_gateway_id
Get gateway_peer2_autodiscovered_gateway_id value.
Notes: The Auto Discovered Gateway peer in this Redundant Group
This attribute is named `gatewayPeer2AutodiscoveredGatewayID` in VSD API.
var gateway_peer2_name
Get gateway_peer2_name value.
Notes: The gateway peer name in this Redundant Group
This attribute is named `gatewayPeer2Name` in VSD API.
var global_metadatas
var heartbeat_interval
Get heartbeat_interval value.
Notes: Heartbeat interval in milliseconds to declare the neighbor dead.
This attribute is named `heartbeatInterval` in VSD API.
var heartbeat_vlanid
Get heartbeat_vlanid value.
Notes: Heartbeat VLAN used for BFD.
This attribute is named `heartbeatVLANID` in VSD API.
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Redundancy Group
var ns_gateways
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var personality
Get personality value.
Notes: Derived personality of the Redundancy Group.
var redundancy_port_ids
Get redundancy_port_ids value.
Notes: Collections resilient port ids associated with this redundant group.
This attribute is named `redundancyPortIDs` in VSD API.
var redundant_gateway_status
Get redundant_gateway_status value.
Notes: The status of Redundant Group.
This attribute is named `redundantGatewayStatus` in VSD API.
var redundant_ports
Methods
def __init__(
self, **kwargs)
Initializes a NSRedundantGatewayGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> nsredundantgatewaygroup = NUNSRedundantGatewayGroup(id=u'xxxx-xxx-xxx-xxx', name=u'NSRedundantGatewayGroup') >>> nsredundantgatewaygroup = NUNSRedundantGatewayGroup(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NSRedundantGatewayGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> nsredundantgatewaygroup = NUNSRedundantGatewayGroup(id=u'xxxx-xxx-xxx-xxx', name=u'NSRedundantGatewayGroup')
>>> nsredundantgatewaygroup = NUNSRedundantGatewayGroup(data=my_dict)
"""
super(NUNSRedundantGatewayGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway_peer1_autodiscovered_gateway_id = None
self._gateway_peer1_id = None
self._gateway_peer1_name = None
self._gateway_peer2_autodiscovered_gateway_id = None
self._gateway_peer2_name = None
self._heartbeat_interval = None
self._heartbeat_vlanid = None
self._redundancy_port_ids = None
self._redundant_gateway_status = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._consecutive_failures_count = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_autodiscovered_gateway_id", remote_name="gatewayPeer1AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_id", remote_name="gatewayPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_name", remote_name="gatewayPeer1Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_autodiscovered_gateway_id", remote_name="gatewayPeer2AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_name", remote_name="gatewayPeer2Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="heartbeat_interval", remote_name="heartbeatInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="heartbeat_vlanid", remote_name="heartbeatVLANID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_port_ids", remote_name="redundancyPortIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundant_gateway_status", remote_name="redundantGatewayStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILED', u'SUCCESS'])
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="consecutive_failures_count", remote_name="consecutiveFailuresCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_gateways = NUNSGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redundant_ports = NURedundantPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNetworkLayout
Represents a NetworkLayout in the VSD
Notes: This API defines the AS number that should be used in the data center as well as the IP address of the route reflector.
class NUNetworkLayout(NURESTObject):
""" Represents a NetworkLayout in the VSD
Notes:
This API defines the AS number that should be used in the data center as well as the IP address of the route reflector.
"""
__rest_name__ = "networklayout"
__resource_name__ = "networklayout"
## Constants
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_SERVICE_TYPE_SUBNET_ONLY = "SUBNET_ONLY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_SERVICE_TYPE_ROUTER_SWITCH = "ROUTER_SWITCH"
CONST_SERVICE_TYPE_ROUTER_ONLY = "ROUTER_ONLY"
def __init__(self, **kwargs):
""" Initializes a NetworkLayout instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> networklayout = NUNetworkLayout(id=u'xxxx-xxx-xxx-xxx', name=u'NetworkLayout')
>>> networklayout = NUNetworkLayout(data=my_dict)
"""
super(NUNetworkLayout, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._service_type = None
self._entity_scope = None
self._route_reflector_ip = None
self._autonomous_system_num = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_type", remote_name="serviceType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ROUTER_ONLY', u'ROUTER_SWITCH', u'SUBNET_ONLY'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="route_reflector_ip", remote_name="routeReflectorIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="autonomous_system_num", remote_name="autonomousSystemNum", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def service_type(self):
""" Get service_type value.
Notes:
Identifies whether L3 or L2 services are supported.
This attribute is named `serviceType` in VSD API.
"""
return self._service_type
@service_type.setter
def service_type(self, value):
""" Set service_type value.
Notes:
Identifies whether L3 or L2 services are supported.
This attribute is named `serviceType` in VSD API.
"""
self._service_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def route_reflector_ip(self):
""" Get route_reflector_ip value.
Notes:
The IP address of the route reflector that can be used by the VSCs
This attribute is named `routeReflectorIP` in VSD API.
"""
return self._route_reflector_ip
@route_reflector_ip.setter
def route_reflector_ip(self, value):
""" Set route_reflector_ip value.
Notes:
The IP address of the route reflector that can be used by the VSCs
This attribute is named `routeReflectorIP` in VSD API.
"""
self._route_reflector_ip = value
@property
def autonomous_system_num(self):
""" Get autonomous_system_num value.
Notes:
The AS number associated with this data center
This attribute is named `autonomousSystemNum` in VSD API.
"""
return self._autonomous_system_num
@autonomous_system_num.setter
def autonomous_system_num(self, value):
""" Set autonomous_system_num value.
Notes:
The AS number associated with this data center
This attribute is named `autonomousSystemNum` in VSD API.
"""
self._autonomous_system_num = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUNetworkLayout
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SERVICE_TYPE_ROUTER_ONLY
var CONST_SERVICE_TYPE_ROUTER_SWITCH
var CONST_SERVICE_TYPE_SUBNET_ONLY
var resource_name
var rest_name
Instance variables
var autonomous_system_num
Get autonomous_system_num value.
Notes: The AS number associated with this data center
This attribute is named `autonomousSystemNum` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var route_reflector_ip
Get route_reflector_ip value.
Notes: The IP address of the route reflector that can be used by the VSCs
This attribute is named `routeReflectorIP` in VSD API.
var service_type
Get service_type value.
Notes: Identifies whether L3 or L2 services are supported.
This attribute is named `serviceType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a NetworkLayout instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> networklayout = NUNetworkLayout(id=u'xxxx-xxx-xxx-xxx', name=u'NetworkLayout') >>> networklayout = NUNetworkLayout(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NetworkLayout instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> networklayout = NUNetworkLayout(id=u'xxxx-xxx-xxx-xxx', name=u'NetworkLayout')
>>> networklayout = NUNetworkLayout(data=my_dict)
"""
super(NUNetworkLayout, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._service_type = None
self._entity_scope = None
self._route_reflector_ip = None
self._autonomous_system_num = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_type", remote_name="serviceType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ROUTER_ONLY', u'ROUTER_SWITCH', u'SUBNET_ONLY'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="route_reflector_ip", remote_name="routeReflectorIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="autonomous_system_num", remote_name="autonomousSystemNum", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUNetworkMacroGroup
Represents a NetworkMacroGroup in the VSD
Notes: Administrators of an enterprise can define macros that are set of IP addresses that identify enterprise networks. These macros can be used in the ACL definitions by network designers and other users to identify access restrictions towards specific enterprise networks.
class NUNetworkMacroGroup(NURESTObject):
""" Represents a NetworkMacroGroup in the VSD
Notes:
Administrators of an enterprise can define macros that are set of IP addresses that identify enterprise networks. These macros can be used in the ACL definitions by network designers and other users to identify access restrictions towards specific enterprise networks.
"""
__rest_name__ = "networkmacrogroup"
__resource_name__ = "networkmacrogroups"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a NetworkMacroGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> networkmacrogroup = NUNetworkMacroGroup(id=u'xxxx-xxx-xxx-xxx', name=u'NetworkMacroGroup')
>>> networkmacrogroup = NUNetworkMacroGroup(data=my_dict)
"""
super(NUNetworkMacroGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_networks = NUEnterpriseNetworksFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the macro group
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the macro group
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the macro group
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the macro group
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUNetworkMacroGroup
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the macro group
var enterprise_networks
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the macro group
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a NetworkMacroGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> networkmacrogroup = NUNetworkMacroGroup(id=u'xxxx-xxx-xxx-xxx', name=u'NetworkMacroGroup') >>> networkmacrogroup = NUNetworkMacroGroup(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a NetworkMacroGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> networkmacrogroup = NUNetworkMacroGroup(id=u'xxxx-xxx-xxx-xxx', name=u'NetworkMacroGroup')
>>> networkmacrogroup = NUNetworkMacroGroup(data=my_dict)
"""
super(NUNetworkMacroGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_networks = NUEnterpriseNetworksFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPATNATPool
Represents a PATNATPool in the VSD
Notes: Represents a PAT NAT Pool object.
class NUPATNATPool(NURESTObject):
""" Represents a PATNATPool in the VSD
Notes:
Represents a PAT NAT Pool object.
"""
__rest_name__ = "patnatpool"
__resource_name__ = "patnatpools"
## Constants
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_ASSOCIATED_GATEWAY_TYPE_GATEWAY = "GATEWAY"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_ASSOCIATED_GATEWAY_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_GATEWAY_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
def __init__(self, **kwargs):
""" Initializes a PATNATPool instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> patnatpool = NUPATNATPool(id=u'xxxx-xxx-xxx-xxx', name=u'PATNATPool')
>>> patnatpool = NUPATNATPool(data=my_dict)
"""
super(NUPATNATPool, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._address_range = None
self._default_patip = None
self._permitted_action = None
self._description = None
self._entity_scope = None
self._associated_gateway_id = None
self._associated_gateway_type = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_range", remote_name="addressRange", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="default_patip", remote_name="defaultPATIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_gateway_id", remote_name="associatedGatewayId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_gateway_type", remote_name="associatedGatewayType", attribute_type=str, is_required=False, is_unique=False, choices=[u'AUTO_DISC_GATEWAY', u'GATEWAY', u'NSGATEWAY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.nat_map_entries = NUNATMapEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the PATNATPool
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the PATNATPool
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address_range(self):
""" Get address_range value.
Notes:
Pool of IP Address that is available for use ex : 130.12.0.0/16
This attribute is named `addressRange` in VSD API.
"""
return self._address_range
@address_range.setter
def address_range(self, value):
""" Set address_range value.
Notes:
Pool of IP Address that is available for use ex : 130.12.0.0/16
This attribute is named `addressRange` in VSD API.
"""
self._address_range = value
@property
def default_patip(self):
""" Get default_patip value.
Notes:
Default PAT IP Address, must belong to the pool above
This attribute is named `defaultPATIP` in VSD API.
"""
return self._default_patip
@default_patip.setter
def default_patip(self, value):
""" Set default_patip value.
Notes:
Default PAT IP Address, must belong to the pool above
This attribute is named `defaultPATIP` in VSD API.
"""
self._default_patip = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def description(self):
""" Get description value.
Notes:
A description of the PATNATPool
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the PATNATPool
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_gateway_id(self):
""" Get associated_gateway_id value.
Notes:
Default PAT IP Address, must belong to the pool above
This attribute is named `associatedGatewayId` in VSD API.
"""
return self._associated_gateway_id
@associated_gateway_id.setter
def associated_gateway_id(self, value):
""" Set associated_gateway_id value.
Notes:
Default PAT IP Address, must belong to the pool above
This attribute is named `associatedGatewayId` in VSD API.
"""
self._associated_gateway_id = value
@property
def associated_gateway_type(self):
""" Get associated_gateway_type value.
Notes:
None
This attribute is named `associatedGatewayType` in VSD API.
"""
return self._associated_gateway_type
@associated_gateway_type.setter
def associated_gateway_type(self, value):
""" Set associated_gateway_type value.
Notes:
None
This attribute is named `associatedGatewayType` in VSD API.
"""
self._associated_gateway_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUPATNATPool
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ASSOCIATED_GATEWAY_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_GATEWAY_TYPE_GATEWAY
var CONST_ASSOCIATED_GATEWAY_TYPE_NSGATEWAY
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var resource_name
var rest_name
Instance variables
var address_range
Get address_range value.
Notes: Pool of IP Address that is available for use ex : 130.12.0.0/16
This attribute is named `addressRange` in VSD API.
var associated_gateway_id
Get associated_gateway_id value.
Notes: Default PAT IP Address, must belong to the pool above
This attribute is named `associatedGatewayId` in VSD API.
var associated_gateway_type
Get associated_gateway_type value.
Notes: None
This attribute is named `associatedGatewayType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var default_patip
Get default_patip value.
Notes: Default PAT IP Address, must belong to the pool above
This attribute is named `defaultPATIP` in VSD API.
var description
Get description value.
Notes: A description of the PATNATPool
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the PATNATPool
var nat_map_entries
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a PATNATPool instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> patnatpool = NUPATNATPool(id=u'xxxx-xxx-xxx-xxx', name=u'PATNATPool') >>> patnatpool = NUPATNATPool(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a PATNATPool instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> patnatpool = NUPATNATPool(id=u'xxxx-xxx-xxx-xxx', name=u'PATNATPool')
>>> patnatpool = NUPATNATPool(data=my_dict)
"""
super(NUPATNATPool, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._address_range = None
self._default_patip = None
self._permitted_action = None
self._description = None
self._entity_scope = None
self._associated_gateway_id = None
self._associated_gateway_type = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_range", remote_name="addressRange", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="default_patip", remote_name="defaultPATIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_gateway_id", remote_name="associatedGatewayId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_gateway_type", remote_name="associatedGatewayType", attribute_type=str, is_required=False, is_unique=False, choices=[u'AUTO_DISC_GATEWAY', u'GATEWAY', u'NSGATEWAY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.nat_map_entries = NUNATMapEntriesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPermission
Represents a Permission in the VSD
Notes: Represents Permitted action on an entity for a group.
class NUPermission(NURESTObject):
""" Represents a Permission in the VSD
Notes:
Represents Permitted action on an entity for a group.
"""
__rest_name__ = "permission"
__resource_name__ = "permissions"
## Constants
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
def __init__(self, **kwargs):
""" Initializes a Permission instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> permission = NUPermission(id=u'xxxx-xxx-xxx-xxx', name=u'Permission')
>>> permission = NUPermission(data=my_dict)
"""
super(NUPermission, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._permitted_entity_description = None
self._permitted_entity_id = None
self._permitted_entity_name = None
self._permitted_entity_type = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=True, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="permitted_entity_description", remote_name="permittedEntityDescription", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_id", remote_name="permittedEntityID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="permitted_entity_name", remote_name="permittedEntityName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_type", remote_name="permittedEntityType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Permission
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Permission
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND/READ/INSTANTIATE an entity.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND/READ/INSTANTIATE an entity.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def permitted_entity_description(self):
""" Get permitted_entity_description value.
Notes:
Description for the permittedEntity
This attribute is named `permittedEntityDescription` in VSD API.
"""
return self._permitted_entity_description
@permitted_entity_description.setter
def permitted_entity_description(self, value):
""" Set permitted_entity_description value.
Notes:
Description for the permittedEntity
This attribute is named `permittedEntityDescription` in VSD API.
"""
self._permitted_entity_description = value
@property
def permitted_entity_id(self):
""" Get permitted_entity_id value.
Notes:
The entity ID for which this permission action is associated against.
This attribute is named `permittedEntityID` in VSD API.
"""
return self._permitted_entity_id
@permitted_entity_id.setter
def permitted_entity_id(self, value):
""" Set permitted_entity_id value.
Notes:
The entity ID for which this permission action is associated against.
This attribute is named `permittedEntityID` in VSD API.
"""
self._permitted_entity_id = value
@property
def permitted_entity_name(self):
""" Get permitted_entity_name value.
Notes:
Name of the entity for which we have given permission.
This attribute is named `permittedEntityName` in VSD API.
"""
return self._permitted_entity_name
@permitted_entity_name.setter
def permitted_entity_name(self, value):
""" Set permitted_entity_name value.
Notes:
Name of the entity for which we have given permission.
This attribute is named `permittedEntityName` in VSD API.
"""
self._permitted_entity_name = value
@property
def permitted_entity_type(self):
""" Get permitted_entity_type value.
Notes:
Type of the entity for which we have given permission.
This attribute is named `permittedEntityType` in VSD API.
"""
return self._permitted_entity_type
@permitted_entity_type.setter
def permitted_entity_type(self, value):
""" Set permitted_entity_type value.
Notes:
Type of the entity for which we have given permission.
This attribute is named `permittedEntityType` in VSD API.
"""
self._permitted_entity_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUPermission
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Permission
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND/READ/INSTANTIATE an entity.
This attribute is named `permittedAction` in VSD API.
var permitted_entity_description
Get permitted_entity_description value.
Notes: Description for the permittedEntity
This attribute is named `permittedEntityDescription` in VSD API.
var permitted_entity_id
Get permitted_entity_id value.
Notes: The entity ID for which this permission action is associated against.
This attribute is named `permittedEntityID` in VSD API.
var permitted_entity_name
Get permitted_entity_name value.
Notes: Name of the entity for which we have given permission.
This attribute is named `permittedEntityName` in VSD API.
var permitted_entity_type
Get permitted_entity_type value.
Notes: Type of the entity for which we have given permission.
This attribute is named `permittedEntityType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a Permission instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> permission = NUPermission(id=u'xxxx-xxx-xxx-xxx', name=u'Permission') >>> permission = NUPermission(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Permission instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> permission = NUPermission(id=u'xxxx-xxx-xxx-xxx', name=u'Permission')
>>> permission = NUPermission(data=my_dict)
"""
super(NUPermission, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._permitted_entity_description = None
self._permitted_entity_id = None
self._permitted_entity_name = None
self._permitted_entity_type = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=True, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="permitted_entity_description", remote_name="permittedEntityDescription", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_id", remote_name="permittedEntityID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="permitted_entity_name", remote_name="permittedEntityName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_entity_type", remote_name="permittedEntityType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPolicyDecision
Represents a PolicyDecision in the VSD
Notes: This object is a read only object that provides the policy decisions for a particular VM interface.
class NUPolicyDecision(NURESTObject):
""" Represents a PolicyDecision in the VSD
Notes:
This object is a read only object that provides the policy decisions for a particular VM interface.
"""
__rest_name__ = "policydecision"
__resource_name__ = "policydecisions"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a PolicyDecision instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> policydecision = NUPolicyDecision(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyDecision')
>>> policydecision = NUPolicyDecision(data=my_dict)
"""
super(NUPolicyDecision, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._egress_acls = None
self._egress_qos = None
self._fip_acls = None
self._ingress_acls = None
self._ingress_adv_fwd = None
self._ingress_external_service_acls = None
self._entity_scope = None
self._qos = None
self._stats = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="egress_acls", remote_name="egressACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="egress_qos", remote_name="egressQos", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_acls", remote_name="fipACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_acls", remote_name="ingressACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_adv_fwd", remote_name="ingressAdvFwd", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_external_service_acls", remote_name="ingressExternalServiceACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="qos", remote_name="qos", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats", remote_name="stats", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def egress_acls(self):
""" Get egress_acls value.
Notes:
List of actual Egress ACLs that will be applied on the interface of this VM
This attribute is named `egressACLs` in VSD API.
"""
return self._egress_acls
@egress_acls.setter
def egress_acls(self, value):
""" Set egress_acls value.
Notes:
List of actual Egress ACLs that will be applied on the interface of this VM
This attribute is named `egressACLs` in VSD API.
"""
self._egress_acls = value
@property
def egress_qos(self):
""" Get egress_qos value.
Notes:
Egress QoS primitive that was selected
This attribute is named `egressQos` in VSD API.
"""
return self._egress_qos
@egress_qos.setter
def egress_qos(self, value):
""" Set egress_qos value.
Notes:
Egress QoS primitive that was selected
This attribute is named `egressQos` in VSD API.
"""
self._egress_qos = value
@property
def fip_acls(self):
""" Get fip_acls value.
Notes:
List of actual Egress ACLs that will be applied on the interface of this VM
This attribute is named `fipACLs` in VSD API.
"""
return self._fip_acls
@fip_acls.setter
def fip_acls(self, value):
""" Set fip_acls value.
Notes:
List of actual Egress ACLs that will be applied on the interface of this VM
This attribute is named `fipACLs` in VSD API.
"""
self._fip_acls = value
@property
def ingress_acls(self):
""" Get ingress_acls value.
Notes:
List of actual Ingress ACLs that will be applied on the interface of this VM
This attribute is named `ingressACLs` in VSD API.
"""
return self._ingress_acls
@ingress_acls.setter
def ingress_acls(self, value):
""" Set ingress_acls value.
Notes:
List of actual Ingress ACLs that will be applied on the interface of this VM
This attribute is named `ingressACLs` in VSD API.
"""
self._ingress_acls = value
@property
def ingress_adv_fwd(self):
""" Get ingress_adv_fwd value.
Notes:
List of actual Ingress Redirect ACLs that will be applied on the interface of this VM
This attribute is named `ingressAdvFwd` in VSD API.
"""
return self._ingress_adv_fwd
@ingress_adv_fwd.setter
def ingress_adv_fwd(self, value):
""" Set ingress_adv_fwd value.
Notes:
List of actual Ingress Redirect ACLs that will be applied on the interface of this VM
This attribute is named `ingressAdvFwd` in VSD API.
"""
self._ingress_adv_fwd = value
@property
def ingress_external_service_acls(self):
""" Get ingress_external_service_acls value.
Notes:
List of actual Ingress External Service ACLs that will be applied on the interface of this VM
This attribute is named `ingressExternalServiceACLs` in VSD API.
"""
return self._ingress_external_service_acls
@ingress_external_service_acls.setter
def ingress_external_service_acls(self, value):
""" Set ingress_external_service_acls value.
Notes:
List of actual Ingress External Service ACLs that will be applied on the interface of this VM
This attribute is named `ingressExternalServiceACLs` in VSD API.
"""
self._ingress_external_service_acls = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def qos(self):
""" Get qos value.
Notes:
QoS primitive that was selected based on inheritance policies
"""
return self._qos
@qos.setter
def qos(self, value):
""" Set qos value.
Notes:
QoS primitive that was selected based on inheritance policies
"""
self._qos = value
@property
def stats(self):
""" Get stats value.
Notes:
Stats primitive that was selected based on inheritance policies
"""
return self._stats
@stats.setter
def stats(self, value):
""" Set stats value.
Notes:
Stats primitive that was selected based on inheritance policies
"""
self._stats = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUPolicyDecision
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var egress_acls
Get egress_acls value.
Notes: List of actual Egress ACLs that will be applied on the interface of this VM
This attribute is named `egressACLs` in VSD API.
var egress_qos
Get egress_qos value.
Notes: Egress QoS primitive that was selected
This attribute is named `egressQos` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var fip_acls
Get fip_acls value.
Notes: List of actual Egress ACLs that will be applied on the interface of this VM
This attribute is named `fipACLs` in VSD API.
var global_metadatas
var id
Get object id
var ingress_acls
Get ingress_acls value.
Notes: List of actual Ingress ACLs that will be applied on the interface of this VM
This attribute is named `ingressACLs` in VSD API.
var ingress_adv_fwd
Get ingress_adv_fwd value.
Notes: List of actual Ingress Redirect ACLs that will be applied on the interface of this VM
This attribute is named `ingressAdvFwd` in VSD API.
var ingress_external_service_acls
Get ingress_external_service_acls value.
Notes: List of actual Ingress External Service ACLs that will be applied on the interface of this VM
This attribute is named `ingressExternalServiceACLs` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var qos
Get qos value.
Notes: QoS primitive that was selected based on inheritance policies
var qoss
var stats
Get stats value.
Notes: Stats primitive that was selected based on inheritance policies
Methods
def __init__(
self, **kwargs)
Initializes a PolicyDecision instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> policydecision = NUPolicyDecision(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyDecision') >>> policydecision = NUPolicyDecision(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a PolicyDecision instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> policydecision = NUPolicyDecision(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyDecision')
>>> policydecision = NUPolicyDecision(data=my_dict)
"""
super(NUPolicyDecision, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._egress_acls = None
self._egress_qos = None
self._fip_acls = None
self._ingress_acls = None
self._ingress_adv_fwd = None
self._ingress_external_service_acls = None
self._entity_scope = None
self._qos = None
self._stats = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="egress_acls", remote_name="egressACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="egress_qos", remote_name="egressQos", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_acls", remote_name="fipACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_acls", remote_name="ingressACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_adv_fwd", remote_name="ingressAdvFwd", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="ingress_external_service_acls", remote_name="ingressExternalServiceACLs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="qos", remote_name="qos", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats", remote_name="stats", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPolicyGroup
Represents a PolicyGroup in the VSD
Notes: PolicyGroup is group of policys on which a user can policies like ACL, QoS, etc.
class NUPolicyGroup(NURESTObject):
""" Represents a PolicyGroup in the VSD
Notes:
PolicyGroup is group of policys on which a user can policies like ACL, QoS, etc.
"""
__rest_name__ = "policygroup"
__resource_name__ = "policygroups"
## Constants
CONST_TYPE_SOFTWARE = "SOFTWARE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_TYPE_HARDWARE = "HARDWARE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a PolicyGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> policygroup = NUPolicyGroup(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyGroup')
>>> policygroup = NUPolicyGroup(data=my_dict)
"""
super(NUPolicyGroup, self).__init__()
# Read/Write Attributes
self._evpn_community_tag = None
self._name = None
self._last_updated_by = None
self._template_id = None
self._description = None
self._entity_scope = None
self._policy_group_id = None
self._external = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="evpn_community_tag", remote_name="EVPNCommunityTag", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_group_id", remote_name="policyGroupID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external", remote_name="external", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'HARDWARE', u'SOFTWARE'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def evpn_community_tag(self):
""" Get evpn_community_tag value.
Notes:
Assigned by VSD. An extended community or other similar BGP attribute to the specific EVPN / IP-VPN NLRI where the VM or network macro is being advertised.
This attribute is named `EVPNCommunityTag` in VSD API.
"""
return self._evpn_community_tag
@evpn_community_tag.setter
def evpn_community_tag(self, value):
""" Set evpn_community_tag value.
Notes:
Assigned by VSD. An extended community or other similar BGP attribute to the specific EVPN / IP-VPN NLRI where the VM or network macro is being advertised.
This attribute is named `EVPNCommunityTag` in VSD API.
"""
self._evpn_community_tag = value
@property
def name(self):
""" Get name value.
Notes:
Name of the policy group
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the policy group
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def template_id(self):
""" Get template_id value.
Notes:
Determines which template ID this policy group belongs to.
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
Determines which template ID this policy group belongs to.
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def description(self):
""" Get description value.
Notes:
Describes this policy group
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Describes this policy group
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_group_id(self):
""" Get policy_group_id value.
Notes:
PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
"""
return self._policy_group_id
@policy_group_id.setter
def policy_group_id(self, value):
""" Set policy_group_id value.
Notes:
PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
"""
self._policy_group_id = value
@property
def external(self):
""" Get external value.
Notes:
Indicates whether this PG is internal to VSP or not.
"""
return self._external
@external.setter
def external(self, value):
""" Set external value.
Notes:
Indicates whether this PG is internal to VSP or not.
"""
self._external = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
Type of policy group.
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
Type of policy group.
"""
self._type = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUPolicyGroup
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_TYPE_HARDWARE
var CONST_TYPE_SOFTWARE
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Describes this policy group
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var evpn_community_tag
Get evpn_community_tag value.
Notes: Assigned by VSD. An extended community or other similar BGP attribute to the specific EVPN / IP-VPN NLRI where the VM or network macro is being advertised.
This attribute is named `EVPNCommunityTag` in VSD API.
var external
Get external value.
Notes: Indicates whether this PG is internal to VSP or not.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the policy group
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_group_id
Get policy_group_id value.
Notes: PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
var template_id
Get template_id value.
Notes: Determines which template ID this policy group belongs to.
This attribute is named `templateID` in VSD API.
var type
Get type value.
Notes: Type of policy group.
var vports
Methods
def __init__(
self, **kwargs)
Initializes a PolicyGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> policygroup = NUPolicyGroup(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyGroup') >>> policygroup = NUPolicyGroup(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a PolicyGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> policygroup = NUPolicyGroup(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyGroup')
>>> policygroup = NUPolicyGroup(data=my_dict)
"""
super(NUPolicyGroup, self).__init__()
# Read/Write Attributes
self._evpn_community_tag = None
self._name = None
self._last_updated_by = None
self._template_id = None
self._description = None
self._entity_scope = None
self._policy_group_id = None
self._external = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="evpn_community_tag", remote_name="EVPNCommunityTag", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_group_id", remote_name="policyGroupID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external", remote_name="external", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'HARDWARE', u'SOFTWARE'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPolicyGroupTemplate
Represents a PolicyGroupTemplate in the VSD
Notes: PolicyGroupTemplate represents the template of a policy group object. PolicyGroup is group of vports on which a user can policies like ACL, QoS, etc.
class NUPolicyGroupTemplate(NURESTObject):
""" Represents a PolicyGroupTemplate in the VSD
Notes:
PolicyGroupTemplate represents the template of a policy group object. PolicyGroup is group of vports on which a user can policies like ACL, QoS, etc.
"""
__rest_name__ = "policygrouptemplate"
__resource_name__ = "policygrouptemplates"
## Constants
CONST_TYPE_SOFTWARE = "SOFTWARE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_TYPE_HARDWARE = "HARDWARE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a PolicyGroupTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> policygrouptemplate = NUPolicyGroupTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyGroupTemplate')
>>> policygrouptemplate = NUPolicyGroupTemplate(data=my_dict)
"""
super(NUPolicyGroupTemplate, self).__init__()
# Read/Write Attributes
self._evpn_community_tag = None
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="evpn_community_tag", remote_name="EVPNCommunityTag", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external", remote_name="external", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'HARDWARE', u'SOFTWARE'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def evpn_community_tag(self):
""" Get evpn_community_tag value.
Notes:
An extended community or other similar BGP attribute to the specific EVPN / IP-VPN NLRI where the VM or network macro is being advertised.
This attribute is named `EVPNCommunityTag` in VSD API.
"""
return self._evpn_community_tag
@evpn_community_tag.setter
def evpn_community_tag(self, value):
""" Set evpn_community_tag value.
Notes:
An extended community or other similar BGP attribute to the specific EVPN / IP-VPN NLRI where the VM or network macro is being advertised.
This attribute is named `EVPNCommunityTag` in VSD API.
"""
self._evpn_community_tag = value
@property
def name(self):
""" Get name value.
Notes:
Name of the policy group
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the policy group
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Describes this policy group
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Describes this policy group
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external(self):
""" Get external value.
Notes:
Indicates whether this PG is internal to VSP or not.
"""
return self._external
@external.setter
def external(self, value):
""" Set external value.
Notes:
Indicates whether this PG is internal to VSP or not.
"""
self._external = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
Type of policy group.
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
Type of policy group.
"""
self._type = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUPolicyGroupTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_TYPE_HARDWARE
var CONST_TYPE_SOFTWARE
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Describes this policy group
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var evpn_community_tag
Get evpn_community_tag value.
Notes: An extended community or other similar BGP attribute to the specific EVPN / IP-VPN NLRI where the VM or network macro is being advertised.
This attribute is named `EVPNCommunityTag` in VSD API.
var external
Get external value.
Notes: Indicates whether this PG is internal to VSP or not.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the policy group
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var type
Get type value.
Notes: Type of policy group.
Methods
def __init__(
self, **kwargs)
Initializes a PolicyGroupTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> policygrouptemplate = NUPolicyGroupTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyGroupTemplate') >>> policygrouptemplate = NUPolicyGroupTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a PolicyGroupTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> policygrouptemplate = NUPolicyGroupTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'PolicyGroupTemplate')
>>> policygrouptemplate = NUPolicyGroupTemplate(data=my_dict)
"""
super(NUPolicyGroupTemplate, self).__init__()
# Read/Write Attributes
self._evpn_community_tag = None
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._external = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="evpn_community_tag", remote_name="EVPNCommunityTag", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external", remote_name="external", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'HARDWARE', u'SOFTWARE'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPort
Represents a Port in the VSD
Notes: Represents Port under a particular gateway object or redundant group object.
class NUPort(NURESTObject):
""" Represents a Port in the VSD
Notes:
Represents Port under a particular gateway object or redundant group object.
"""
__rest_name__ = "port"
__resource_name__ = "ports"
## Constants
CONST_PORT_TYPE_NETWORK = "NETWORK"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_STATUS_READY = "READY"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_STATUS_INITIALIZED = "INITIALIZED"
CONST_STATUS_MISMATCH = "MISMATCH"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PORT_TYPE_ACCESS = "ACCESS"
CONST_STATUS_ORPHAN = "ORPHAN"
def __init__(self, **kwargs):
""" Initializes a Port instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> port = NUPort(id=u'xxxx-xxx-xxx-xxx', name=u'Port')
>>> port = NUPort(data=my_dict)
"""
super(NUPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._template_id = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._entity_scope = None
self._port_type = None
self._is_resilient = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._associated_redundant_port_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="is_resilient", remote_name="isResilient", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_redundant_port_id", remote_name="associatedRedundantPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vlan_range(self):
""" Get vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
return self._vlan_range
@vlan_range.setter
def vlan_range(self, value):
""" Set vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
self._vlan_range = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Port
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Port
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def physical_name(self):
""" Get physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
return self._physical_name
@physical_name.setter
def physical_name(self, value):
""" Set physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
self._physical_name = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port_type(self):
""" Get port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
return self._port_type
@port_type.setter
def port_type(self, value):
""" Set port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
self._port_type = value
@property
def is_resilient(self):
""" Get is_resilient value.
Notes:
States if this port instance is resilient (redundant). An example would be a Multi-Chassis LAG port.
This attribute is named `isResilient` in VSD API.
"""
return self._is_resilient
@is_resilient.setter
def is_resilient(self, value):
""" Set is_resilient value.
Notes:
States if this port instance is resilient (redundant). An example would be a Multi-Chassis LAG port.
This attribute is named `isResilient` in VSD API.
"""
self._is_resilient = value
@property
def use_user_mnemonic(self):
""" Get use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
return self._use_user_mnemonic
@use_user_mnemonic.setter
def use_user_mnemonic(self, value):
""" Set use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
self._use_user_mnemonic = value
@property
def user_mnemonic(self):
""" Get user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
return self._user_mnemonic
@user_mnemonic.setter
def user_mnemonic(self, value):
""" Set user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
self._user_mnemonic = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def associated_redundant_port_id(self):
""" Get associated_redundant_port_id value.
Notes:
ID of the redundant port to which this Port instance may be associated to.
This attribute is named `associatedRedundantPortID` in VSD API.
"""
return self._associated_redundant_port_id
@associated_redundant_port_id.setter
def associated_redundant_port_id(self, value):
""" Set associated_redundant_port_id value.
Notes:
ID of the redundant port to which this Port instance may be associated to.
This attribute is named `associatedRedundantPortID` in VSD API.
"""
self._associated_redundant_port_id = value
@property
def status(self):
""" Get status value.
Notes:
Status of the port.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Status of the port.
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUPort
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PORT_TYPE_ACCESS
var CONST_PORT_TYPE_NETWORK
var CONST_STATUS_INITIALIZED
var CONST_STATUS_MISMATCH
var CONST_STATUS_ORPHAN
var CONST_STATUS_READY
var resource_name
var rest_name
Instance variables
var alarms
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var associated_redundant_port_id
Get associated_redundant_port_id value.
Notes: ID of the redundant port to which this Port instance may be associated to.
This attribute is named `associatedRedundantPortID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var is_resilient
Get is_resilient value.
Notes: States if this port instance is resilient (redundant). An example would be a Multi-Chassis LAG port.
This attribute is named `isResilient` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Port
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var physical_name
Get physical_name value.
Notes: Identifier of the Port
This attribute is named `physicalName` in VSD API.
var port_type
Get port_type value.
Notes: Type of the Port.
This attribute is named `portType` in VSD API.
var status
Get status value.
Notes: Status of the port.
var template_id
Get template_id value.
Notes: The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
var use_user_mnemonic
Get use_user_mnemonic value.
Notes: determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
var user_mnemonic
Get user_mnemonic value.
Notes: user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
var vlan_range
Get vlan_range value.
Notes: VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
var vlans
Methods
def __init__(
self, **kwargs)
Initializes a Port instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> port = NUPort(id=u'xxxx-xxx-xxx-xxx', name=u'Port') >>> port = NUPort(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Port instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> port = NUPort(id=u'xxxx-xxx-xxx-xxx', name=u'Port')
>>> port = NUPort(data=my_dict)
"""
super(NUPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._template_id = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._entity_scope = None
self._port_type = None
self._is_resilient = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._associated_redundant_port_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="is_resilient", remote_name="isResilient", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_redundant_port_id", remote_name="associatedRedundantPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPortTemplate
Represents a PortTemplate in the VSD
Notes: Represents a Port Template object under a given gateway template object.
class NUPortTemplate(NURESTObject):
""" Represents a PortTemplate in the VSD
Notes:
Represents a Port Template object under a given gateway template object.
"""
__rest_name__ = "porttemplate"
__resource_name__ = "porttemplates"
## Constants
CONST_PORT_TYPE_NETWORK = "NETWORK"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PORT_TYPE_ACCESS = "ACCESS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a PortTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> porttemplate = NUPortTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'PortTemplate')
>>> porttemplate = NUPortTemplate(data=my_dict)
"""
super(NUPortTemplate, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._description = None
self._physical_name = None
self._entity_scope = None
self._port_type = None
self._associated_egress_qos_policy_id = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlan_templates = NUVLANTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vlan_range(self):
""" Get vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
return self._vlan_range
@vlan_range.setter
def vlan_range(self, value):
""" Set vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
self._vlan_range = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Port
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Port
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def physical_name(self):
""" Get physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
return self._physical_name
@physical_name.setter
def physical_name(self, value):
""" Set physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
self._physical_name = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port_type(self):
""" Get port_type value.
Notes:
Type of the Port - NETWORK, ACCESS Possible values are ACCESS, NETWORK, .
This attribute is named `portType` in VSD API.
"""
return self._port_type
@port_type.setter
def port_type(self, value):
""" Set port_type value.
Notes:
Type of the Port - NETWORK, ACCESS Possible values are ACCESS, NETWORK, .
This attribute is named `portType` in VSD API.
"""
self._port_type = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUPortTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PORT_TYPE_ACCESS
var CONST_PORT_TYPE_NETWORK
var resource_name
var rest_name
Instance variables
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Port
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var physical_name
Get physical_name value.
Notes: Identifier of the Port
This attribute is named `physicalName` in VSD API.
var port_type
Get port_type value.
Notes: Type of the Port - NETWORK, ACCESS Possible values are ACCESS, NETWORK, .
This attribute is named `portType` in VSD API.
var vlan_range
Get vlan_range value.
Notes: VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
var vlan_templates
Methods
def __init__(
self, **kwargs)
Initializes a PortTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> porttemplate = NUPortTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'PortTemplate') >>> porttemplate = NUPortTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a PortTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> porttemplate = NUPortTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'PortTemplate')
>>> porttemplate = NUPortTemplate(data=my_dict)
"""
super(NUPortTemplate, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._description = None
self._physical_name = None
self._entity_scope = None
self._port_type = None
self._associated_egress_qos_policy_id = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlan_templates = NUVLANTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUPublicNetworkMacro
Represents a PublicNetworkMacro in the VSD
Notes: Similar to the enterprise macros, the public network macro allows an administrator of an enterprise to define range of subnets that can be used by users in the ACL definition
class NUPublicNetworkMacro(NURESTObject):
""" Represents a PublicNetworkMacro in the VSD
Notes:
Similar to the enterprise macros, the public network macro allows an administrator of an enterprise to define range of subnets that can be used by users in the ACL definition
"""
__rest_name__ = "publicnetwork"
__resource_name__ = "publicnetworks"
## Constants
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a PublicNetworkMacro instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> publicnetworkmacro = NUPublicNetworkMacro(id=u'xxxx-xxx-xxx-xxx', name=u'PublicNetworkMacro')
>>> publicnetworkmacro = NUPublicNetworkMacro(data=my_dict)
"""
super(NUPublicNetworkMacro, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._address = None
self._netmask = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def name(self):
""" Get name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
self._address = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet defined
"""
self._netmask = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUPublicNetworkMacro
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the subnet defined
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a PublicNetworkMacro instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> publicnetworkmacro = NUPublicNetworkMacro(id=u'xxxx-xxx-xxx-xxx', name=u'PublicNetworkMacro') >>> publicnetworkmacro = NUPublicNetworkMacro(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a PublicNetworkMacro instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> publicnetworkmacro = NUPublicNetworkMacro(id=u'xxxx-xxx-xxx-xxx', name=u'PublicNetworkMacro')
>>> publicnetworkmacro = NUPublicNetworkMacro(data=my_dict)
"""
super(NUPublicNetworkMacro, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._address = None
self._netmask = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUQOS
Represents a QOS in the VSD
Notes: The object manipulates the QoS parameters attached to a domain, zone, or subnet.
class NUQOS(NURESTObject):
""" Represents a QOS in the VSD
Notes:
The object manipulates the QoS parameters attached to a domain, zone, or subnet.
"""
__rest_name__ = "qos"
__resource_name__ = "qos"
## Constants
CONST_SERVICE_CLASS_H = "H"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_SERVICE_CLASS_A = "A"
CONST_SERVICE_CLASS_B = "B"
CONST_SERVICE_CLASS_C = "C"
CONST_SERVICE_CLASS_D = "D"
CONST_SERVICE_CLASS_E = "E"
CONST_SERVICE_CLASS_F = "F"
CONST_SERVICE_CLASS_G = "G"
CONST_SERVICE_CLASS_NONE = "NONE"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a QOS instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> qos = NUQOS(id=u'xxxx-xxx-xxx-xxx', name=u'QOS')
>>> qos = NUQOS(data=my_dict)
"""
super(NUQOS, self).__init__()
# Read/Write Attributes
self._fip_committed_burst_size = None
self._fip_committed_information_rate = None
self._fip_peak_burst_size = None
self._fip_peak_information_rate = None
self._fip_rate_limiting_active = None
self._bum_committed_burst_size = None
self._bum_committed_information_rate = None
self._bum_peak_burst_size = None
self._bum_peak_information_rate = None
self._bum_rate_limiting_active = None
self._name = None
self._last_updated_by = None
self._rate_limiting_active = None
self._active = None
self._peak = None
self._service_class = None
self._description = None
self._rewrite_forwarding_class = None
self._entity_scope = None
self._committed_burst_size = None
self._committed_information_rate = None
self._trusted_forwarding_class = None
self._assoc_qos_id = None
self._associated_dscp_forwarding_class_table_id = None
self._associated_dscp_forwarding_class_table_name = None
self._burst = None
self._external_id = None
self.expose_attribute(local_name="fip_committed_burst_size", remote_name="FIPCommittedBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_committed_information_rate", remote_name="FIPCommittedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_peak_burst_size", remote_name="FIPPeakBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_peak_information_rate", remote_name="FIPPeakInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_rate_limiting_active", remote_name="FIPRateLimitingActive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_committed_burst_size", remote_name="BUMCommittedBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_committed_information_rate", remote_name="BUMCommittedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_peak_burst_size", remote_name="BUMPeakBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_peak_information_rate", remote_name="BUMPeakInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_rate_limiting_active", remote_name="BUMRateLimitingActive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="rate_limiting_active", remote_name="rateLimitingActive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak", remote_name="peak", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_class", remote_name="serviceClass", attribute_type=str, is_required=True, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="rewrite_forwarding_class", remote_name="rewriteForwardingClass", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="committed_burst_size", remote_name="committedBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="committed_information_rate", remote_name="committedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="trusted_forwarding_class", remote_name="trustedForwardingClass", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_qos_id", remote_name="assocQosId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_dscp_forwarding_class_table_id", remote_name="associatedDSCPForwardingClassTableID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_dscp_forwarding_class_table_name", remote_name="associatedDSCPForwardingClassTableName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="burst", remote_name="burst", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def fip_committed_burst_size(self):
""" Get fip_committed_burst_size value.
Notes:
Committed burst size setting in kilo-bytes (kilo-octets) for FIP Shaper.
This attribute is named `FIPCommittedBurstSize` in VSD API.
"""
return self._fip_committed_burst_size
@fip_committed_burst_size.setter
def fip_committed_burst_size(self, value):
""" Set fip_committed_burst_size value.
Notes:
Committed burst size setting in kilo-bytes (kilo-octets) for FIP Shaper.
This attribute is named `FIPCommittedBurstSize` in VSD API.
"""
self._fip_committed_burst_size = value
@property
def fip_committed_information_rate(self):
""" Get fip_committed_information_rate value.
Notes:
Committed information rate setting in Mb/s for FIP Shaper.
This attribute is named `FIPCommittedInformationRate` in VSD API.
"""
return self._fip_committed_information_rate
@fip_committed_information_rate.setter
def fip_committed_information_rate(self, value):
""" Set fip_committed_information_rate value.
Notes:
Committed information rate setting in Mb/s for FIP Shaper.
This attribute is named `FIPCommittedInformationRate` in VSD API.
"""
self._fip_committed_information_rate = value
@property
def fip_peak_burst_size(self):
""" Get fip_peak_burst_size value.
Notes:
Peak burst size setting in kilo-bytes (kilo-octets) for FIP rate limiting.
This attribute is named `FIPPeakBurstSize` in VSD API.
"""
return self._fip_peak_burst_size
@fip_peak_burst_size.setter
def fip_peak_burst_size(self, value):
""" Set fip_peak_burst_size value.
Notes:
Peak burst size setting in kilo-bytes (kilo-octets) for FIP rate limiting.
This attribute is named `FIPPeakBurstSize` in VSD API.
"""
self._fip_peak_burst_size = value
@property
def fip_peak_information_rate(self):
""" Get fip_peak_information_rate value.
Notes:
Peak rate setting for FIP rate limiting in Mb/s;
This attribute is named `FIPPeakInformationRate` in VSD API.
"""
return self._fip_peak_information_rate
@fip_peak_information_rate.setter
def fip_peak_information_rate(self, value):
""" Set fip_peak_information_rate value.
Notes:
Peak rate setting for FIP rate limiting in Mb/s;
This attribute is named `FIPPeakInformationRate` in VSD API.
"""
self._fip_peak_information_rate = value
@property
def fip_rate_limiting_active(self):
""" Get fip_rate_limiting_active value.
Notes:
Flag the indicates whether FIP rate limiting is enabled or disabled
This attribute is named `FIPRateLimitingActive` in VSD API.
"""
return self._fip_rate_limiting_active
@fip_rate_limiting_active.setter
def fip_rate_limiting_active(self, value):
""" Set fip_rate_limiting_active value.
Notes:
Flag the indicates whether FIP rate limiting is enabled or disabled
This attribute is named `FIPRateLimitingActive` in VSD API.
"""
self._fip_rate_limiting_active = value
@property
def bum_committed_burst_size(self):
""" Get bum_committed_burst_size value.
Notes:
Committed burst size setting in kilo-bytes (kilo-octets) for BUM Shaper.
This attribute is named `BUMCommittedBurstSize` in VSD API.
"""
return self._bum_committed_burst_size
@bum_committed_burst_size.setter
def bum_committed_burst_size(self, value):
""" Set bum_committed_burst_size value.
Notes:
Committed burst size setting in kilo-bytes (kilo-octets) for BUM Shaper.
This attribute is named `BUMCommittedBurstSize` in VSD API.
"""
self._bum_committed_burst_size = value
@property
def bum_committed_information_rate(self):
""" Get bum_committed_information_rate value.
Notes:
Committed information rate setting in Mb/s for BUM Shaper.
This attribute is named `BUMCommittedInformationRate` in VSD API.
"""
return self._bum_committed_information_rate
@bum_committed_information_rate.setter
def bum_committed_information_rate(self, value):
""" Set bum_committed_information_rate value.
Notes:
Committed information rate setting in Mb/s for BUM Shaper.
This attribute is named `BUMCommittedInformationRate` in VSD API.
"""
self._bum_committed_information_rate = value
@property
def bum_peak_burst_size(self):
""" Get bum_peak_burst_size value.
Notes:
Peak burst size setting in kilo-bytes (kilo-octets) for Broadcast/Multicast rate limiting (BUM).
This attribute is named `BUMPeakBurstSize` in VSD API.
"""
return self._bum_peak_burst_size
@bum_peak_burst_size.setter
def bum_peak_burst_size(self, value):
""" Set bum_peak_burst_size value.
Notes:
Peak burst size setting in kilo-bytes (kilo-octets) for Broadcast/Multicast rate limiting (BUM).
This attribute is named `BUMPeakBurstSize` in VSD API.
"""
self._bum_peak_burst_size = value
@property
def bum_peak_information_rate(self):
""" Get bum_peak_information_rate value.
Notes:
Peak rate setting in Mb/s for Broadcast/Multicast rate limiting
This attribute is named `BUMPeakInformationRate` in VSD API.
"""
return self._bum_peak_information_rate
@bum_peak_information_rate.setter
def bum_peak_information_rate(self, value):
""" Set bum_peak_information_rate value.
Notes:
Peak rate setting in Mb/s for Broadcast/Multicast rate limiting
This attribute is named `BUMPeakInformationRate` in VSD API.
"""
self._bum_peak_information_rate = value
@property
def bum_rate_limiting_active(self):
""" Get bum_rate_limiting_active value.
Notes:
Flag the indicates whether Broadcast/Multicast rate limiting is enabled or disabled
This attribute is named `BUMRateLimitingActive` in VSD API.
"""
return self._bum_rate_limiting_active
@bum_rate_limiting_active.setter
def bum_rate_limiting_active(self, value):
""" Set bum_rate_limiting_active value.
Notes:
Flag the indicates whether Broadcast/Multicast rate limiting is enabled or disabled
This attribute is named `BUMRateLimitingActive` in VSD API.
"""
self._bum_rate_limiting_active = value
@property
def name(self):
""" Get name value.
Notes:
A unique name of the QoS object
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
A unique name of the QoS object
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def rate_limiting_active(self):
""" Get rate_limiting_active value.
Notes:
Identifies if rate limiting must be implemented
This attribute is named `rateLimitingActive` in VSD API.
"""
return self._rate_limiting_active
@rate_limiting_active.setter
def rate_limiting_active(self, value):
""" Set rate_limiting_active value.
Notes:
Identifies if rate limiting must be implemented
This attribute is named `rateLimitingActive` in VSD API.
"""
self._rate_limiting_active = value
@property
def active(self):
""" Get active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
If enabled, it means that this ACL or QOS entry is active
"""
self._active = value
@property
def peak(self):
""" Get peak value.
Notes:
Peak Information Rate : Peak bandwidth that is allowed from each VM in Mb/s; only whole values allowed and 'INFINITY' if rate limiting is disabled.
"""
return self._peak
@peak.setter
def peak(self, value):
""" Set peak value.
Notes:
Peak Information Rate : Peak bandwidth that is allowed from each VM in Mb/s; only whole values allowed and 'INFINITY' if rate limiting is disabled.
"""
self._peak = value
@property
def service_class(self):
""" Get service_class value.
Notes:
Class of service to be used. Service classes in order of priority are A(1), B(2), C(3), D(4), E(5), F(6), G(7) and H(8) Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `serviceClass` in VSD API.
"""
return self._service_class
@service_class.setter
def service_class(self, value):
""" Set service_class value.
Notes:
Class of service to be used. Service classes in order of priority are A(1), B(2), C(3), D(4), E(5), F(6), G(7) and H(8) Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `serviceClass` in VSD API.
"""
self._service_class = value
@property
def description(self):
""" Get description value.
Notes:
A description of the QoS object
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the QoS object
"""
self._description = value
@property
def rewrite_forwarding_class(self):
""" Get rewrite_forwarding_class value.
Notes:
Specifies if the rewrite flag is set for the QoS policy / template
This attribute is named `rewriteForwardingClass` in VSD API.
"""
return self._rewrite_forwarding_class
@rewrite_forwarding_class.setter
def rewrite_forwarding_class(self, value):
""" Set rewrite_forwarding_class value.
Notes:
Specifies if the rewrite flag is set for the QoS policy / template
This attribute is named `rewriteForwardingClass` in VSD API.
"""
self._rewrite_forwarding_class = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def committed_burst_size(self):
""" Get committed_burst_size value.
Notes:
Committed Burst Size : Burst size associated with the rate limiter in kilo-bytes (kilo-octets); only whole values are supported.
This attribute is named `committedBurstSize` in VSD API.
"""
return self._committed_burst_size
@committed_burst_size.setter
def committed_burst_size(self, value):
""" Set committed_burst_size value.
Notes:
Committed Burst Size : Burst size associated with the rate limiter in kilo-bytes (kilo-octets); only whole values are supported.
This attribute is named `committedBurstSize` in VSD API.
"""
self._committed_burst_size = value
@property
def committed_information_rate(self):
""" Get committed_information_rate value.
Notes:
Committed Information Rate : Committed bandwidth that is allowed from each VM in Mb/s; only whole values supported.
This attribute is named `committedInformationRate` in VSD API.
"""
return self._committed_information_rate
@committed_information_rate.setter
def committed_information_rate(self, value):
""" Set committed_information_rate value.
Notes:
Committed Information Rate : Committed bandwidth that is allowed from each VM in Mb/s; only whole values supported.
This attribute is named `committedInformationRate` in VSD API.
"""
self._committed_information_rate = value
@property
def trusted_forwarding_class(self):
""" Get trusted_forwarding_class value.
Notes:
Specifies if the trusted flag is set for the QoS policy / template
This attribute is named `trustedForwardingClass` in VSD API.
"""
return self._trusted_forwarding_class
@trusted_forwarding_class.setter
def trusted_forwarding_class(self, value):
""" Set trusted_forwarding_class value.
Notes:
Specifies if the trusted flag is set for the QoS policy / template
This attribute is named `trustedForwardingClass` in VSD API.
"""
self._trusted_forwarding_class = value
@property
def assoc_qos_id(self):
""" Get assoc_qos_id value.
Notes:
ID of object associated with this QoS object
This attribute is named `assocQosId` in VSD API.
"""
return self._assoc_qos_id
@assoc_qos_id.setter
def assoc_qos_id(self, value):
""" Set assoc_qos_id value.
Notes:
ID of object associated with this QoS object
This attribute is named `assocQosId` in VSD API.
"""
self._assoc_qos_id = value
@property
def associated_dscp_forwarding_class_table_id(self):
""" Get associated_dscp_forwarding_class_table_id value.
Notes:
ID of the DSCP->Forwarding Class used by this Qos Policy
This attribute is named `associatedDSCPForwardingClassTableID` in VSD API.
"""
return self._associated_dscp_forwarding_class_table_id
@associated_dscp_forwarding_class_table_id.setter
def associated_dscp_forwarding_class_table_id(self, value):
""" Set associated_dscp_forwarding_class_table_id value.
Notes:
ID of the DSCP->Forwarding Class used by this Qos Policy
This attribute is named `associatedDSCPForwardingClassTableID` in VSD API.
"""
self._associated_dscp_forwarding_class_table_id = value
@property
def associated_dscp_forwarding_class_table_name(self):
""" Get associated_dscp_forwarding_class_table_name value.
Notes:
Name of the DSCP->Forwarding Class used by this Qos Policy
This attribute is named `associatedDSCPForwardingClassTableName` in VSD API.
"""
return self._associated_dscp_forwarding_class_table_name
@associated_dscp_forwarding_class_table_name.setter
def associated_dscp_forwarding_class_table_name(self, value):
""" Set associated_dscp_forwarding_class_table_name value.
Notes:
Name of the DSCP->Forwarding Class used by this Qos Policy
This attribute is named `associatedDSCPForwardingClassTableName` in VSD API.
"""
self._associated_dscp_forwarding_class_table_name = value
@property
def burst(self):
""" Get burst value.
Notes:
Peak Burst Size : The maximum burst size associated with the rate limiter in kilo-bytes (kilo-octets); only whole values allowed and 'INFINITY' if rate limiting is disabled.
"""
return self._burst
@burst.setter
def burst(self, value):
""" Set burst value.
Notes:
Peak Burst Size : The maximum burst size associated with the rate limiter in kilo-bytes (kilo-octets); only whole values allowed and 'INFINITY' if rate limiting is disabled.
"""
self._burst = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUQOS
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_SERVICE_CLASS_A
var CONST_SERVICE_CLASS_B
var CONST_SERVICE_CLASS_C
var CONST_SERVICE_CLASS_D
var CONST_SERVICE_CLASS_E
var CONST_SERVICE_CLASS_F
var CONST_SERVICE_CLASS_G
var CONST_SERVICE_CLASS_H
var CONST_SERVICE_CLASS_NONE
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: If enabled, it means that this ACL or QOS entry is active
var assoc_qos_id
Get assoc_qos_id value.
Notes: ID of object associated with this QoS object
This attribute is named `assocQosId` in VSD API.
var associated_dscp_forwarding_class_table_id
Get associated_dscp_forwarding_class_table_id value.
Notes: ID of the DSCP->Forwarding Class used by this Qos Policy
This attribute is named `associatedDSCPForwardingClassTableID` in VSD API.
var associated_dscp_forwarding_class_table_name
Get associated_dscp_forwarding_class_table_name value.
Notes: Name of the DSCP->Forwarding Class used by this Qos Policy
This attribute is named `associatedDSCPForwardingClassTableName` in VSD API.
var bum_committed_burst_size
Get bum_committed_burst_size value.
Notes: Committed burst size setting in kilo-bytes (kilo-octets) for BUM Shaper.
This attribute is named `BUMCommittedBurstSize` in VSD API.
var bum_committed_information_rate
Get bum_committed_information_rate value.
Notes: Committed information rate setting in Mb/s for BUM Shaper.
This attribute is named `BUMCommittedInformationRate` in VSD API.
var bum_peak_burst_size
Get bum_peak_burst_size value.
Notes: Peak burst size setting in kilo-bytes (kilo-octets) for Broadcast/Multicast rate limiting (BUM).
This attribute is named `BUMPeakBurstSize` in VSD API.
var bum_peak_information_rate
Get bum_peak_information_rate value.
Notes: Peak rate setting in Mb/s for Broadcast/Multicast rate limiting
This attribute is named `BUMPeakInformationRate` in VSD API.
var bum_rate_limiting_active
Get bum_rate_limiting_active value.
Notes: Flag the indicates whether Broadcast/Multicast rate limiting is enabled or disabled
This attribute is named `BUMRateLimitingActive` in VSD API.
var burst
Get burst value.
Notes: Peak Burst Size : The maximum burst size associated with the rate limiter in kilo-bytes (kilo-octets); only whole values allowed and 'INFINITY' if rate limiting is disabled.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var committed_burst_size
Get committed_burst_size value.
Notes: Committed Burst Size : Burst size associated with the rate limiter in kilo-bytes (kilo-octets); only whole values are supported.
This attribute is named `committedBurstSize` in VSD API.
var committed_information_rate
Get committed_information_rate value.
Notes: Committed Information Rate : Committed bandwidth that is allowed from each VM in Mb/s; only whole values supported.
This attribute is named `committedInformationRate` in VSD API.
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the QoS object
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var fip_committed_burst_size
Get fip_committed_burst_size value.
Notes: Committed burst size setting in kilo-bytes (kilo-octets) for FIP Shaper.
This attribute is named `FIPCommittedBurstSize` in VSD API.
var fip_committed_information_rate
Get fip_committed_information_rate value.
Notes: Committed information rate setting in Mb/s for FIP Shaper.
This attribute is named `FIPCommittedInformationRate` in VSD API.
var fip_peak_burst_size
Get fip_peak_burst_size value.
Notes: Peak burst size setting in kilo-bytes (kilo-octets) for FIP rate limiting.
This attribute is named `FIPPeakBurstSize` in VSD API.
var fip_peak_information_rate
Get fip_peak_information_rate value.
Notes: Peak rate setting for FIP rate limiting in Mb/s;
This attribute is named `FIPPeakInformationRate` in VSD API.
var fip_rate_limiting_active
Get fip_rate_limiting_active value.
Notes: Flag the indicates whether FIP rate limiting is enabled or disabled
This attribute is named `FIPRateLimitingActive` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: A unique name of the QoS object
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var peak
Get peak value.
Notes: Peak Information Rate : Peak bandwidth that is allowed from each VM in Mb/s; only whole values allowed and 'INFINITY' if rate limiting is disabled.
var rate_limiting_active
Get rate_limiting_active value.
Notes: Identifies if rate limiting must be implemented
This attribute is named `rateLimitingActive` in VSD API.
var rewrite_forwarding_class
Get rewrite_forwarding_class value.
Notes: Specifies if the rewrite flag is set for the QoS policy / template
This attribute is named `rewriteForwardingClass` in VSD API.
var service_class
Get service_class value.
Notes: Class of service to be used. Service classes in order of priority are A(1), B(2), C(3), D(4), E(5), F(6), G(7) and H(8) Possible values are NONE, A, B, C, D, E, F, G, H, .
This attribute is named `serviceClass` in VSD API.
var trusted_forwarding_class
Get trusted_forwarding_class value.
Notes: Specifies if the trusted flag is set for the QoS policy / template
This attribute is named `trustedForwardingClass` in VSD API.
var vms
Methods
def __init__(
self, **kwargs)
Initializes a QOS instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> qos = NUQOS(id=u'xxxx-xxx-xxx-xxx', name=u'QOS') >>> qos = NUQOS(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a QOS instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> qos = NUQOS(id=u'xxxx-xxx-xxx-xxx', name=u'QOS')
>>> qos = NUQOS(data=my_dict)
"""
super(NUQOS, self).__init__()
# Read/Write Attributes
self._fip_committed_burst_size = None
self._fip_committed_information_rate = None
self._fip_peak_burst_size = None
self._fip_peak_information_rate = None
self._fip_rate_limiting_active = None
self._bum_committed_burst_size = None
self._bum_committed_information_rate = None
self._bum_peak_burst_size = None
self._bum_peak_information_rate = None
self._bum_rate_limiting_active = None
self._name = None
self._last_updated_by = None
self._rate_limiting_active = None
self._active = None
self._peak = None
self._service_class = None
self._description = None
self._rewrite_forwarding_class = None
self._entity_scope = None
self._committed_burst_size = None
self._committed_information_rate = None
self._trusted_forwarding_class = None
self._assoc_qos_id = None
self._associated_dscp_forwarding_class_table_id = None
self._associated_dscp_forwarding_class_table_name = None
self._burst = None
self._external_id = None
self.expose_attribute(local_name="fip_committed_burst_size", remote_name="FIPCommittedBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_committed_information_rate", remote_name="FIPCommittedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_peak_burst_size", remote_name="FIPPeakBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_peak_information_rate", remote_name="FIPPeakInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="fip_rate_limiting_active", remote_name="FIPRateLimitingActive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_committed_burst_size", remote_name="BUMCommittedBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_committed_information_rate", remote_name="BUMCommittedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_peak_burst_size", remote_name="BUMPeakBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_peak_information_rate", remote_name="BUMPeakInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="bum_rate_limiting_active", remote_name="BUMRateLimitingActive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="rate_limiting_active", remote_name="rateLimitingActive", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak", remote_name="peak", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_class", remote_name="serviceClass", attribute_type=str, is_required=True, is_unique=False, choices=[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'NONE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="rewrite_forwarding_class", remote_name="rewriteForwardingClass", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="committed_burst_size", remote_name="committedBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="committed_information_rate", remote_name="committedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="trusted_forwarding_class", remote_name="trustedForwardingClass", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_qos_id", remote_name="assocQosId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_dscp_forwarding_class_table_id", remote_name="associatedDSCPForwardingClassTableID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_dscp_forwarding_class_table_name", remote_name="associatedDSCPForwardingClassTableName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="burst", remote_name="burst", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NURateLimiter
Represents a RateLimiter in the VSD
Notes: Rate Limiter object that contains peak, burst and cir. It can be associated with Egress QOS policy objects.
class NURateLimiter(NURESTObject):
""" Represents a RateLimiter in the VSD
Notes:
Rate Limiter object that contains peak, burst and cir. It can be associated with Egress QOS policy objects.
"""
__rest_name__ = "ratelimiter"
__resource_name__ = "ratelimiters"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a RateLimiter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ratelimiter = NURateLimiter(id=u'xxxx-xxx-xxx-xxx', name=u'RateLimiter')
>>> ratelimiter = NURateLimiter(data=my_dict)
"""
super(NURateLimiter, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._peak_burst_size = None
self._peak_information_rate = None
self._description = None
self._entity_scope = None
self._committed_information_rate = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_burst_size", remote_name="peakBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_information_rate", remote_name="peakInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="committed_information_rate", remote_name="committedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
A unique name of the Rate Limiter object
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
A unique name of the Rate Limiter object
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def peak_burst_size(self):
""" Get peak_burst_size value.
Notes:
Peak Burst Size : The maximum burst size associated with the rate limiter in kilo-bits; only whole values are supported.
This attribute is named `peakBurstSize` in VSD API.
"""
return self._peak_burst_size
@peak_burst_size.setter
def peak_burst_size(self, value):
""" Set peak_burst_size value.
Notes:
Peak Burst Size : The maximum burst size associated with the rate limiter in kilo-bits; only whole values are supported.
This attribute is named `peakBurstSize` in VSD API.
"""
self._peak_burst_size = value
@property
def peak_information_rate(self):
""" Get peak_information_rate value.
Notes:
Peak Information Rate : Peak bandwidth allowed in Mb/s; only whole values supported.
This attribute is named `peakInformationRate` in VSD API.
"""
return self._peak_information_rate
@peak_information_rate.setter
def peak_information_rate(self, value):
""" Set peak_information_rate value.
Notes:
Peak Information Rate : Peak bandwidth allowed in Mb/s; only whole values supported.
This attribute is named `peakInformationRate` in VSD API.
"""
self._peak_information_rate = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Rate Limiter object
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Rate Limiter object
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def committed_information_rate(self):
""" Get committed_information_rate value.
Notes:
Committed Information Rate : Committed bandwidth that is allowed in Mb/s; only whole values supported.
This attribute is named `committedInformationRate` in VSD API.
"""
return self._committed_information_rate
@committed_information_rate.setter
def committed_information_rate(self, value):
""" Set committed_information_rate value.
Notes:
Committed Information Rate : Committed bandwidth that is allowed in Mb/s; only whole values supported.
This attribute is named `committedInformationRate` in VSD API.
"""
self._committed_information_rate = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NURateLimiter
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var committed_information_rate
Get committed_information_rate value.
Notes: Committed Information Rate : Committed bandwidth that is allowed in Mb/s; only whole values supported.
This attribute is named `committedInformationRate` in VSD API.
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Rate Limiter object
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: A unique name of the Rate Limiter object
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var peak_burst_size
Get peak_burst_size value.
Notes: Peak Burst Size : The maximum burst size associated with the rate limiter in kilo-bits; only whole values are supported.
This attribute is named `peakBurstSize` in VSD API.
var peak_information_rate
Get peak_information_rate value.
Notes: Peak Information Rate : Peak bandwidth allowed in Mb/s; only whole values supported.
This attribute is named `peakInformationRate` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a RateLimiter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> ratelimiter = NURateLimiter(id=u'xxxx-xxx-xxx-xxx', name=u'RateLimiter') >>> ratelimiter = NURateLimiter(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a RateLimiter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> ratelimiter = NURateLimiter(id=u'xxxx-xxx-xxx-xxx', name=u'RateLimiter')
>>> ratelimiter = NURateLimiter(data=my_dict)
"""
super(NURateLimiter, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._peak_burst_size = None
self._peak_information_rate = None
self._description = None
self._entity_scope = None
self._committed_information_rate = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_burst_size", remote_name="peakBurstSize", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_information_rate", remote_name="peakInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="committed_information_rate", remote_name="committedInformationRate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NURedirectionTarget
Represents a RedirectionTarget in the VSD
Notes: A group/collection of vports that belong to the same domain.
class NURedirectionTarget(NURESTObject):
""" Represents a RedirectionTarget in the VSD
Notes:
A group/collection of vports that belong to the same domain.
"""
__rest_name__ = "redirectiontarget"
__resource_name__ = "redirectiontargets"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_END_POINT_TYPE_L3 = "L3"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_END_POINT_TYPE_NONE = "NONE"
CONST_TRIGGER_TYPE_NONE = "NONE"
CONST_END_POINT_TYPE_VIRTUAL_WIRE = "VIRTUAL_WIRE"
CONST_TRIGGER_TYPE_GARP = "GARP"
def __init__(self, **kwargs):
""" Initializes a RedirectionTarget instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redirectiontarget = NURedirectionTarget(id=u'xxxx-xxx-xxx-xxx', name=u'RedirectionTarget')
>>> redirectiontarget = NURedirectionTarget(data=my_dict)
"""
super(NURedirectionTarget, self).__init__()
# Read/Write Attributes
self._esi = None
self._name = None
self._last_updated_by = None
self._redundancy_enabled = None
self._template_id = None
self._description = None
self._virtual_network_id = None
self._end_point_type = None
self._entity_scope = None
self._trigger_type = None
self._external_id = None
self.expose_attribute(local_name="esi", remote_name="ESI", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_enabled", remote_name="redundancyEnabled", attribute_type=bool, is_required=True, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="virtual_network_id", remote_name="virtualNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="end_point_type", remote_name="endPointType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L3', u'NONE', u'VIRTUAL_WIRE'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="trigger_type", remote_name="triggerType", attribute_type=str, is_required=False, is_unique=False, choices=[u'GARP', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.virtual_ips = NUVirtualIPsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def esi(self):
""" Get esi value.
Notes:
ESI id, globally unique
This attribute is named `ESI` in VSD API.
"""
return self._esi
@esi.setter
def esi(self, value):
""" Set esi value.
Notes:
ESI id, globally unique
This attribute is named `ESI` in VSD API.
"""
self._esi = value
@property
def name(self):
""" Get name value.
Notes:
Name of this redirection target
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of this redirection target
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def redundancy_enabled(self):
""" Get redundancy_enabled value.
Notes:
Allow/Disallow redundant appliances and VIP
This attribute is named `redundancyEnabled` in VSD API.
"""
return self._redundancy_enabled
@redundancy_enabled.setter
def redundancy_enabled(self, value):
""" Set redundancy_enabled value.
Notes:
Allow/Disallow redundant appliances and VIP
This attribute is named `redundancyEnabled` in VSD API.
"""
self._redundancy_enabled = value
@property
def template_id(self):
""" Get template_id value.
Notes:
Template to which this redirection target belongs to
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
Template to which this redirection target belongs to
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def description(self):
""" Get description value.
Notes:
Description of this redirection target
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of this redirection target
"""
self._description = value
@property
def virtual_network_id(self):
""" Get virtual_network_id value.
Notes:
Auto Generated by VSD. Each vPortTag with redundancy=enable and EndpointType != none will have a globally unique ESI & VNID generated by VSD
This attribute is named `virtualNetworkID` in VSD API.
"""
return self._virtual_network_id
@virtual_network_id.setter
def virtual_network_id(self, value):
""" Set virtual_network_id value.
Notes:
Auto Generated by VSD. Each vPortTag with redundancy=enable and EndpointType != none will have a globally unique ESI & VNID generated by VSD
This attribute is named `virtualNetworkID` in VSD API.
"""
self._virtual_network_id = value
@property
def end_point_type(self):
""" Get end_point_type value.
Notes:
EndpointType defines the type of header rewrite and forwarding performed by VRS when the endpoint is used as a PBR destination. NONE type is deprecated. Possible values are NONE, L3, VIRTUAL_WIRE, .
This attribute is named `endPointType` in VSD API.
"""
return self._end_point_type
@end_point_type.setter
def end_point_type(self, value):
""" Set end_point_type value.
Notes:
EndpointType defines the type of header rewrite and forwarding performed by VRS when the endpoint is used as a PBR destination. NONE type is deprecated. Possible values are NONE, L3, VIRTUAL_WIRE, .
This attribute is named `endPointType` in VSD API.
"""
self._end_point_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def trigger_type(self):
""" Get trigger_type value.
Notes:
Trigger type, THIS IS READ ONLY. Possible values are NONE, GARP, .
This attribute is named `triggerType` in VSD API.
"""
return self._trigger_type
@trigger_type.setter
def trigger_type(self, value):
""" Set trigger_type value.
Notes:
Trigger type, THIS IS READ ONLY. Possible values are NONE, GARP, .
This attribute is named `triggerType` in VSD API.
"""
self._trigger_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NURedirectionTarget
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_END_POINT_TYPE_L3
var CONST_END_POINT_TYPE_NONE
var CONST_END_POINT_TYPE_VIRTUAL_WIRE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_TRIGGER_TYPE_GARP
var CONST_TRIGGER_TYPE_NONE
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of this redirection target
var end_point_type
Get end_point_type value.
Notes: EndpointType defines the type of header rewrite and forwarding performed by VRS when the endpoint is used as a PBR destination. NONE type is deprecated. Possible values are NONE, L3, VIRTUAL_WIRE, .
This attribute is named `endPointType` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var esi
Get esi value.
Notes: ESI id, globally unique
This attribute is named `ESI` in VSD API.
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of this redirection target
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var redundancy_enabled
Get redundancy_enabled value.
Notes: Allow/Disallow redundant appliances and VIP
This attribute is named `redundancyEnabled` in VSD API.
var template_id
Get template_id value.
Notes: Template to which this redirection target belongs to
This attribute is named `templateID` in VSD API.
var trigger_type
Get trigger_type value.
Notes: Trigger type, THIS IS READ ONLY. Possible values are NONE, GARP, .
This attribute is named `triggerType` in VSD API.
var virtual_ips
var virtual_network_id
Get virtual_network_id value.
Notes: Auto Generated by VSD. Each vPortTag with redundancy=enable and EndpointType != none will have a globally unique ESI & VNID generated by VSD
This attribute is named `virtualNetworkID` in VSD API.
var vports
Methods
def __init__(
self, **kwargs)
Initializes a RedirectionTarget instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> redirectiontarget = NURedirectionTarget(id=u'xxxx-xxx-xxx-xxx', name=u'RedirectionTarget') >>> redirectiontarget = NURedirectionTarget(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a RedirectionTarget instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redirectiontarget = NURedirectionTarget(id=u'xxxx-xxx-xxx-xxx', name=u'RedirectionTarget')
>>> redirectiontarget = NURedirectionTarget(data=my_dict)
"""
super(NURedirectionTarget, self).__init__()
# Read/Write Attributes
self._esi = None
self._name = None
self._last_updated_by = None
self._redundancy_enabled = None
self._template_id = None
self._description = None
self._virtual_network_id = None
self._end_point_type = None
self._entity_scope = None
self._trigger_type = None
self._external_id = None
self.expose_attribute(local_name="esi", remote_name="ESI", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_enabled", remote_name="redundancyEnabled", attribute_type=bool, is_required=True, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="virtual_network_id", remote_name="virtualNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="end_point_type", remote_name="endPointType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L3', u'NONE', u'VIRTUAL_WIRE'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="trigger_type", remote_name="triggerType", attribute_type=str, is_required=False, is_unique=False, choices=[u'GARP', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.virtual_ips = NUVirtualIPsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NURedirectionTargetTemplate
Represents a RedirectionTargetTemplate in the VSD
Notes: Template for a vporttag. It can be created only at the template level and available for all instances.
class NURedirectionTargetTemplate(NURESTObject):
""" Represents a RedirectionTargetTemplate in the VSD
Notes:
Template for a vporttag. It can be created only at the template level and available for all instances.
"""
__rest_name__ = "redirectiontargettemplate"
__resource_name__ = "redirectiontargettemplates"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_END_POINT_TYPE_L3 = "L3"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_END_POINT_TYPE_NONE = "NONE"
CONST_TRIGGER_TYPE_NONE = "NONE"
CONST_END_POINT_TYPE_VIRTUAL_WIRE = "VIRTUAL_WIRE"
CONST_TRIGGER_TYPE_GARP = "GARP"
def __init__(self, **kwargs):
""" Initializes a RedirectionTargetTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redirectiontargettemplate = NURedirectionTargetTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'RedirectionTargetTemplate')
>>> redirectiontargettemplate = NURedirectionTargetTemplate(data=my_dict)
"""
super(NURedirectionTargetTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._redundancy_enabled = None
self._description = None
self._end_point_type = None
self._entity_scope = None
self._trigger_type = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_enabled", remote_name="redundancyEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="end_point_type", remote_name="endPointType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L3', u'NONE', u'VIRTUAL_WIRE'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="trigger_type", remote_name="triggerType", attribute_type=str, is_required=False, is_unique=False, choices=[u'GARP', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of this redirection target template
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of this redirection target template
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def redundancy_enabled(self):
""" Get redundancy_enabled value.
Notes:
Allow/Disallow redundant appliances and VIP
This attribute is named `redundancyEnabled` in VSD API.
"""
return self._redundancy_enabled
@redundancy_enabled.setter
def redundancy_enabled(self, value):
""" Set redundancy_enabled value.
Notes:
Allow/Disallow redundant appliances and VIP
This attribute is named `redundancyEnabled` in VSD API.
"""
self._redundancy_enabled = value
@property
def description(self):
""" Get description value.
Notes:
Description of this redirection target template
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of this redirection target template
"""
self._description = value
@property
def end_point_type(self):
""" Get end_point_type value.
Notes:
VPortTagEndPointType is an enum. It defines the type of header rewrite and forwarding performed by VRS when the endpoint is used as a PBR destination. Possible values are NONE, L3, VIRTUAL_WIRE.
This attribute is named `endPointType` in VSD API.
"""
return self._end_point_type
@end_point_type.setter
def end_point_type(self, value):
""" Set end_point_type value.
Notes:
VPortTagEndPointType is an enum. It defines the type of header rewrite and forwarding performed by VRS when the endpoint is used as a PBR destination. Possible values are NONE, L3, VIRTUAL_WIRE.
This attribute is named `endPointType` in VSD API.
"""
self._end_point_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def trigger_type(self):
""" Get trigger_type value.
Notes:
Trigger type, could be NONE/GARP - THIS IS READONLY
This attribute is named `triggerType` in VSD API.
"""
return self._trigger_type
@trigger_type.setter
def trigger_type(self, value):
""" Set trigger_type value.
Notes:
Trigger type, could be NONE/GARP - THIS IS READONLY
This attribute is named `triggerType` in VSD API.
"""
self._trigger_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NURedirectionTargetTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_END_POINT_TYPE_L3
var CONST_END_POINT_TYPE_NONE
var CONST_END_POINT_TYPE_VIRTUAL_WIRE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_TRIGGER_TYPE_GARP
var CONST_TRIGGER_TYPE_NONE
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of this redirection target template
var end_point_type
Get end_point_type value.
Notes: VPortTagEndPointType is an enum. It defines the type of header rewrite and forwarding performed by VRS when the endpoint is used as a PBR destination. Possible values are NONE, L3, VIRTUAL_WIRE.
This attribute is named `endPointType` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of this redirection target template
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var redundancy_enabled
Get redundancy_enabled value.
Notes: Allow/Disallow redundant appliances and VIP
This attribute is named `redundancyEnabled` in VSD API.
var trigger_type
Get trigger_type value.
Notes: Trigger type, could be NONE/GARP - THIS IS READONLY
This attribute is named `triggerType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a RedirectionTargetTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> redirectiontargettemplate = NURedirectionTargetTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'RedirectionTargetTemplate') >>> redirectiontargettemplate = NURedirectionTargetTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a RedirectionTargetTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redirectiontargettemplate = NURedirectionTargetTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'RedirectionTargetTemplate')
>>> redirectiontargettemplate = NURedirectionTargetTemplate(data=my_dict)
"""
super(NURedirectionTargetTemplate, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._redundancy_enabled = None
self._description = None
self._end_point_type = None
self._entity_scope = None
self._trigger_type = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundancy_enabled", remote_name="redundancyEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="end_point_type", remote_name="endPointType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L3', u'NONE', u'VIRTUAL_WIRE'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="trigger_type", remote_name="triggerType", attribute_type=str, is_required=False, is_unique=False, choices=[u'GARP', u'NONE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NURedundancyGroup
Represents a RedundancyGroup in the VSD
Notes: Represents Redundant Group formed by two Gateways.
class NURedundancyGroup(NURESTObject):
""" Represents a RedundancyGroup in the VSD
Notes:
Represents Redundant Group formed by two Gateways.
"""
__rest_name__ = "redundancygroup"
__resource_name__ = "redundancygroups"
## Constants
CONST_PERSONALITY_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_PERSONALITY_VSA = "VSA"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERSONALITY_VSG = "VSG"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_PERSONALITY_OTHER = "OTHER"
CONST_PERSONALITY_NSG = "NSG"
CONST_REDUNDANT_GATEWAY_STATUS_SUCCESS = "SUCCESS"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERSONALITY_VRSG = "VRSG"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_PERSONALITY_DC7X50 = "DC7X50"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_REDUNDANT_GATEWAY_STATUS_FAILED = "FAILED"
def __init__(self, **kwargs):
""" Initializes a RedundancyGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redundancygroup = NURedundancyGroup(id=u'xxxx-xxx-xxx-xxx', name=u'RedundancyGroup')
>>> redundancygroup = NURedundancyGroup(data=my_dict)
"""
super(NURedundancyGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway_peer1_autodiscovered_gateway_id = None
self._gateway_peer1_id = None
self._gateway_peer1_name = None
self._gateway_peer2_autodiscovered_gateway_id = None
self._gateway_peer2_name = None
self._redundant_gateway_status = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._vtep = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_autodiscovered_gateway_id", remote_name="gatewayPeer1AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_id", remote_name="gatewayPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_name", remote_name="gatewayPeer1Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_autodiscovered_gateway_id", remote_name="gatewayPeer2AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_name", remote_name="gatewayPeer2Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundant_gateway_status", remote_name="redundantGatewayStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILED', u'SUCCESS'])
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="vtep", remote_name="vtep", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.gateways = NUGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.wan_services = NUWANServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ports = NUPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsg_redundant_ports = NUVsgRedundantPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsg_redundant_ports = NUVsgRedundantPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the Redundancy Group
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Redundancy Group
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_peer1_autodiscovered_gateway_id(self):
""" Get gateway_peer1_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway configuration owner in this Redundant Group.
This attribute is named `gatewayPeer1AutodiscoveredGatewayID` in VSD API.
"""
return self._gateway_peer1_autodiscovered_gateway_id
@gateway_peer1_autodiscovered_gateway_id.setter
def gateway_peer1_autodiscovered_gateway_id(self, value):
""" Set gateway_peer1_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway configuration owner in this Redundant Group.
This attribute is named `gatewayPeer1AutodiscoveredGatewayID` in VSD API.
"""
self._gateway_peer1_autodiscovered_gateway_id = value
@property
def gateway_peer1_id(self):
""" Get gateway_peer1_id value.
Notes:
The gateway configuration owner in this Redundant Group. when Redundant Group is deleted this gateway will recieve vport associations
This attribute is named `gatewayPeer1ID` in VSD API.
"""
return self._gateway_peer1_id
@gateway_peer1_id.setter
def gateway_peer1_id(self, value):
""" Set gateway_peer1_id value.
Notes:
The gateway configuration owner in this Redundant Group. when Redundant Group is deleted this gateway will recieve vport associations
This attribute is named `gatewayPeer1ID` in VSD API.
"""
self._gateway_peer1_id = value
@property
def gateway_peer1_name(self):
""" Get gateway_peer1_name value.
Notes:
The gateway configuration owner name in this Redundant Group
This attribute is named `gatewayPeer1Name` in VSD API.
"""
return self._gateway_peer1_name
@gateway_peer1_name.setter
def gateway_peer1_name(self, value):
""" Set gateway_peer1_name value.
Notes:
The gateway configuration owner name in this Redundant Group
This attribute is named `gatewayPeer1Name` in VSD API.
"""
self._gateway_peer1_name = value
@property
def gateway_peer2_autodiscovered_gateway_id(self):
""" Get gateway_peer2_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway peer in this Redundant Group
This attribute is named `gatewayPeer2AutodiscoveredGatewayID` in VSD API.
"""
return self._gateway_peer2_autodiscovered_gateway_id
@gateway_peer2_autodiscovered_gateway_id.setter
def gateway_peer2_autodiscovered_gateway_id(self, value):
""" Set gateway_peer2_autodiscovered_gateway_id value.
Notes:
The Auto Discovered Gateway peer in this Redundant Group
This attribute is named `gatewayPeer2AutodiscoveredGatewayID` in VSD API.
"""
self._gateway_peer2_autodiscovered_gateway_id = value
@property
def gateway_peer2_name(self):
""" Get gateway_peer2_name value.
Notes:
The gateway peer name in this Redundant Group
This attribute is named `gatewayPeer2Name` in VSD API.
"""
return self._gateway_peer2_name
@gateway_peer2_name.setter
def gateway_peer2_name(self, value):
""" Set gateway_peer2_name value.
Notes:
The gateway peer name in this Redundant Group
This attribute is named `gatewayPeer2Name` in VSD API.
"""
self._gateway_peer2_name = value
@property
def redundant_gateway_status(self):
""" Get redundant_gateway_status value.
Notes:
The status of Redundant Group, possible values are FAILED, SUCCESS Possible values are FAILED, SUCCESS, .
This attribute is named `redundantGatewayStatus` in VSD API.
"""
return self._redundant_gateway_status
@redundant_gateway_status.setter
def redundant_gateway_status(self, value):
""" Set redundant_gateway_status value.
Notes:
The status of Redundant Group, possible values are FAILED, SUCCESS Possible values are FAILED, SUCCESS, .
This attribute is named `redundantGatewayStatus` in VSD API.
"""
self._redundant_gateway_status = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway Possible values are USE, READ, ALL, INSTANTIATE, EXTEND, DEPLOY, .
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway Possible values are USE, READ, ALL, INSTANTIATE, EXTEND, DEPLOY, .
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def personality(self):
""" Get personality value.
Notes:
derived personality of the Redundancy Group - VSG,VRSG,NSG,OTHER Possible values are VSG, VSA, VRSG, DC7X50, NSG, HARDWARE_VTEP, OTHER, .
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
derived personality of the Redundancy Group - VSG,VRSG,NSG,OTHER Possible values are VSG, VSA, VRSG, DC7X50, NSG, HARDWARE_VTEP, OTHER, .
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Redundancy Group
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Redundancy Group
"""
self._description = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
The enterprise associated with this Redundant Group. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
The enterprise associated with this Redundant Group. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def vtep(self):
""" Get vtep value.
Notes:
Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
"""
return self._vtep
@vtep.setter
def vtep(self, value):
""" Set vtep value.
Notes:
Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
"""
self._vtep = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NURedundancyGroup
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PERSONALITY_DC7X50
var CONST_PERSONALITY_HARDWARE_VTEP
var CONST_PERSONALITY_NSG
var CONST_PERSONALITY_OTHER
var CONST_PERSONALITY_VRSG
var CONST_PERSONALITY_VSA
var CONST_PERSONALITY_VSG
var CONST_REDUNDANT_GATEWAY_STATUS_FAILED
var CONST_REDUNDANT_GATEWAY_STATUS_SUCCESS
var resource_name
var rest_name
Instance variables
var alarms
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the Redundancy Group
var enterprise_id
Get enterprise_id value.
Notes: The enterprise associated with this Redundant Group. This is a read only attribute
This attribute is named `enterpriseID` in VSD API.
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_peer1_autodiscovered_gateway_id
Get gateway_peer1_autodiscovered_gateway_id value.
Notes: The Auto Discovered Gateway configuration owner in this Redundant Group.
This attribute is named `gatewayPeer1AutodiscoveredGatewayID` in VSD API.
var gateway_peer1_id
Get gateway_peer1_id value.
Notes: The gateway configuration owner in this Redundant Group. when Redundant Group is deleted this gateway will recieve vport associations
This attribute is named `gatewayPeer1ID` in VSD API.
var gateway_peer1_name
Get gateway_peer1_name value.
Notes: The gateway configuration owner name in this Redundant Group
This attribute is named `gatewayPeer1Name` in VSD API.
var gateway_peer2_autodiscovered_gateway_id
Get gateway_peer2_autodiscovered_gateway_id value.
Notes: The Auto Discovered Gateway peer in this Redundant Group
This attribute is named `gatewayPeer2AutodiscoveredGatewayID` in VSD API.
var gateway_peer2_name
Get gateway_peer2_name value.
Notes: The gateway peer name in this Redundant Group
This attribute is named `gatewayPeer2Name` in VSD API.
var gateways
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Redundancy Group
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway Possible values are USE, READ, ALL, INSTANTIATE, EXTEND, DEPLOY, .
This attribute is named `permittedAction` in VSD API.
var personality
Get personality value.
Notes: derived personality of the Redundancy Group - VSG,VRSG,NSG,OTHER Possible values are VSG, VSA, VRSG, DC7X50, NSG, HARDWARE_VTEP, OTHER, .
var ports
var redundant_gateway_status
Get redundant_gateway_status value.
Notes: The status of Redundant Group, possible values are FAILED, SUCCESS Possible values are FAILED, SUCCESS, .
This attribute is named `redundantGatewayStatus` in VSD API.
var vsg_redundant_ports
var vtep
Get vtep value.
Notes: Represent the system ID or the Virtual IP of a service used by a Gateway (VSG for now) to establish a tunnel with a remote VSG or hypervisor. The format of this field is consistent with an IP address.
var wan_services
Methods
def __init__(
self, **kwargs)
Initializes a RedundancyGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> redundancygroup = NURedundancyGroup(id=u'xxxx-xxx-xxx-xxx', name=u'RedundancyGroup') >>> redundancygroup = NURedundancyGroup(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a RedundancyGroup instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redundancygroup = NURedundancyGroup(id=u'xxxx-xxx-xxx-xxx', name=u'RedundancyGroup')
>>> redundancygroup = NURedundancyGroup(data=my_dict)
"""
super(NURedundancyGroup, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway_peer1_autodiscovered_gateway_id = None
self._gateway_peer1_id = None
self._gateway_peer1_name = None
self._gateway_peer2_autodiscovered_gateway_id = None
self._gateway_peer2_name = None
self._redundant_gateway_status = None
self._permitted_action = None
self._personality = None
self._description = None
self._enterprise_id = None
self._entity_scope = None
self._vtep = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_autodiscovered_gateway_id", remote_name="gatewayPeer1AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_id", remote_name="gatewayPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer1_name", remote_name="gatewayPeer1Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_autodiscovered_gateway_id", remote_name="gatewayPeer2AutodiscoveredGatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_peer2_name", remote_name="gatewayPeer2Name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="redundant_gateway_status", remote_name="redundantGatewayStatus", attribute_type=str, is_required=False, is_unique=False, choices=[u'FAILED', u'SUCCESS'])
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC7X50', u'HARDWARE_VTEP', u'NSG', u'OTHER', u'VRSG', u'VSA', u'VSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="vtep", remote_name="vtep", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.gateways = NUGatewaysFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.wan_services = NUWANServicesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ports = NUPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsg_redundant_ports = NUVsgRedundantPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsg_redundant_ports = NUVsgRedundantPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NURedundantPort
Represents a RedundantPort in the VSD
Notes: Represents a Port under a particular gateway object or redundant group object.
class NURedundantPort(NURESTObject):
""" Represents a RedundantPort in the VSD
Notes:
Represents a Port under a particular gateway object or redundant group object.
"""
__rest_name__ = "nsredundantport"
__resource_name__ = "nsredundantports"
## Constants
CONST_PORT_TYPE_NETWORK = "NETWORK"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_STATUS_READY = "READY"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_STATUS_INITIALIZED = "INITIALIZED"
CONST_STATUS_MISMATCH = "MISMATCH"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PORT_TYPE_ACCESS = "ACCESS"
CONST_STATUS_ORPHAN = "ORPHAN"
def __init__(self, **kwargs):
""" Initializes a RedundantPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redundantport = NURedundantPort(id=u'xxxx-xxx-xxx-xxx', name=u'RedundantPort')
>>> redundantport = NURedundantPort(data=my_dict)
"""
super(NURedundantPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._infrastructure_profile_id = None
self._entity_scope = None
self._port_peer1_id = None
self._port_peer2_id = None
self._port_type = None
self._use_untagged_heartbeat_vlan = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_peer1_id", remote_name="portPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_peer2_id", remote_name="portPeer2ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="use_untagged_heartbeat_vlan", remote_name="useUntaggedHeartbeatVlan", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_ports = NUNSPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vlan_range(self):
""" Get vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
return self._vlan_range
@vlan_range.setter
def vlan_range(self, value):
""" Set vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
self._vlan_range = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Port
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Port
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def physical_name(self):
""" Get physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
return self._physical_name
@physical_name.setter
def physical_name(self, value):
""" Set physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
self._physical_name = value
@property
def infrastructure_profile_id(self):
""" Get infrastructure_profile_id value.
Notes:
The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
return self._infrastructure_profile_id
@infrastructure_profile_id.setter
def infrastructure_profile_id(self, value):
""" Set infrastructure_profile_id value.
Notes:
The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
"""
self._infrastructure_profile_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port_peer1_id(self):
""" Get port_peer1_id value.
Notes:
The master gateway peer port id.
This attribute is named `portPeer1ID` in VSD API.
"""
return self._port_peer1_id
@port_peer1_id.setter
def port_peer1_id(self, value):
""" Set port_peer1_id value.
Notes:
The master gateway peer port id.
This attribute is named `portPeer1ID` in VSD API.
"""
self._port_peer1_id = value
@property
def port_peer2_id(self):
""" Get port_peer2_id value.
Notes:
The slave gateway peer port id.
This attribute is named `portPeer2ID` in VSD API.
"""
return self._port_peer2_id
@port_peer2_id.setter
def port_peer2_id(self, value):
""" Set port_peer2_id value.
Notes:
The slave gateway peer port id.
This attribute is named `portPeer2ID` in VSD API.
"""
self._port_peer2_id = value
@property
def port_type(self):
""" Get port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
return self._port_type
@port_type.setter
def port_type(self, value):
""" Set port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
self._port_type = value
@property
def use_untagged_heartbeat_vlan(self):
""" Get use_untagged_heartbeat_vlan value.
Notes:
A flag to indicate if for this redundant port an untagged heartbeat VLAN is to be used. If this is not set then will use the heartbeat VLAN set by the NS redundant group
This attribute is named `useUntaggedHeartbeatVlan` in VSD API.
"""
return self._use_untagged_heartbeat_vlan
@use_untagged_heartbeat_vlan.setter
def use_untagged_heartbeat_vlan(self, value):
""" Set use_untagged_heartbeat_vlan value.
Notes:
A flag to indicate if for this redundant port an untagged heartbeat VLAN is to be used. If this is not set then will use the heartbeat VLAN set by the NS redundant group
This attribute is named `useUntaggedHeartbeatVlan` in VSD API.
"""
self._use_untagged_heartbeat_vlan = value
@property
def use_user_mnemonic(self):
""" Get use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
return self._use_user_mnemonic
@use_user_mnemonic.setter
def use_user_mnemonic(self, value):
""" Set use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
self._use_user_mnemonic = value
@property
def user_mnemonic(self):
""" Get user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
return self._user_mnemonic
@user_mnemonic.setter
def user_mnemonic(self, value):
""" Set user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
self._user_mnemonic = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def status(self):
""" Get status value.
Notes:
Status of the port.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Status of the port.
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NURedundantPort
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PORT_TYPE_ACCESS
var CONST_PORT_TYPE_NETWORK
var CONST_STATUS_INITIALIZED
var CONST_STATUS_MISMATCH
var CONST_STATUS_ORPHAN
var CONST_STATUS_READY
var resource_name
var rest_name
Instance variables
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var infrastructure_profile_id
Get infrastructure_profile_id value.
Notes: The ID of the infrastructure profile this instance is associated with.
This attribute is named `infrastructureProfileID` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Port
var ns_ports
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var physical_name
Get physical_name value.
Notes: Identifier of the Port
This attribute is named `physicalName` in VSD API.
var port_peer1_id
Get port_peer1_id value.
Notes: The master gateway peer port id.
This attribute is named `portPeer1ID` in VSD API.
var port_peer2_id
Get port_peer2_id value.
Notes: The slave gateway peer port id.
This attribute is named `portPeer2ID` in VSD API.
var port_type
Get port_type value.
Notes: Type of the Port.
This attribute is named `portType` in VSD API.
var status
Get status value.
Notes: Status of the port.
var use_untagged_heartbeat_vlan
Get use_untagged_heartbeat_vlan value.
Notes: A flag to indicate if for this redundant port an untagged heartbeat VLAN is to be used. If this is not set then will use the heartbeat VLAN set by the NS redundant group
This attribute is named `useUntaggedHeartbeatVlan` in VSD API.
var use_user_mnemonic
Get use_user_mnemonic value.
Notes: determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
var user_mnemonic
Get user_mnemonic value.
Notes: user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
var vlan_range
Get vlan_range value.
Notes: VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
var vlans
Methods
def __init__(
self, **kwargs)
Initializes a RedundantPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> redundantport = NURedundantPort(id=u'xxxx-xxx-xxx-xxx', name=u'RedundantPort') >>> redundantport = NURedundantPort(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a RedundantPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> redundantport = NURedundantPort(id=u'xxxx-xxx-xxx-xxx', name=u'RedundantPort')
>>> redundantport = NURedundantPort(data=my_dict)
"""
super(NURedundantPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._infrastructure_profile_id = None
self._entity_scope = None
self._port_peer1_id = None
self._port_peer2_id = None
self._port_type = None
self._use_untagged_heartbeat_vlan = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="infrastructure_profile_id", remote_name="infrastructureProfileID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_peer1_id", remote_name="portPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_peer2_id", remote_name="portPeer2ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="use_untagged_heartbeat_vlan", remote_name="useUntaggedHeartbeatVlan", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ns_ports = NUNSPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
Represents a SharedNetworkResource in the VSD
Notes: This defines shared infrastructure resources that are created by user with CSPROOT role. These resources can be used by all the enterprises in the data center for various purposes. Examples of shared resources are public subnet, floating subnet, public L2 domain, etc.
Ancestors (in MRO)
- NUSharedNetworkResource
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
Instance variables
Get access_restriction_enabled value.
Notes: Boolean indicates that this shared network resource is avaiable to everyone by default or not
This attribute is named `accessRestrictionEnabled` in VSD API.
Get address value.
Notes: Address configured on the shared resource
Get back_haul_route_distinguisher value.
Notes: backHaulRouteDistinguisher of the Shared Resource
This attribute is named `backHaulRouteDistinguisher` in VSD API.
Get back_haul_route_target value.
Notes: backHaulRouteTarget of the Shared Resource
This attribute is named `backHaulRouteTarget` in VSD API.
Get back_haul_vnid value.
Notes: backHaulVNID of the Shared Resource
This attribute is named `backHaulVNID` in VSD API.
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
Get creation date
Get description value.
Notes: Description of the shared resource
Get dhcp_managed value.
Notes: true if DHCP is enabled else it is false. This value is always true for network resource of type PUBLIC or FLOATING.
This attribute is named `DHCPManaged` in VSD API.
Get domain_route_distinguisher value.
Notes: Route distinguisher configured on the shared resource
This attribute is named `domainRouteDistinguisher` in VSD API.
Get domain_route_target value.
Notes: Route target configured on the shared resource
This attribute is named `domainRouteTarget` in VSD API.
Get ecmp_count value.
Notes: Domain specific Equal-cost multi-path routing count, ECMPCount = 1 means no ECMP
This attribute is named `ECMPCount` in VSD API.
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
Get gateway value.
Notes: Gatemask configured on the shared resource
Get object id
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
Get last update date
Get local id
Get name value.
Notes: Name of the shared resource. Valid characters are alphabets, numbers, space and hyphen( - ).
Get netmask value.
Notes: Netmask configured on the shared resource
Get owner
Get parent id
Get parent
Get parent type
Get permitted_action_type value.
Notes: Permitted action on this shared network resource
This attribute is named `permittedActionType` in VSD API.
Get shared_resource_parent_id value.
Notes: Parent ID of the floating IP subnet to which this FIP subnet must be attached. If empty it will be created in a new domain.
This attribute is named `sharedResourceParentID` in VSD API.
Get type value.
Notes: Type of the shared resource.
Get underlay value.
Notes: Indicates whether this shared subnet is in underlay or not.
Get uplink_gw_vlan_attachment_id value.
Notes: VLAN ID to which this vport must be attached
This attribute is named `uplinkGWVlanAttachmentID` in VSD API.
Get uplink_interface_ip value.
Notes: IP address of the host interface
This attribute is named `uplinkInterfaceIP` in VSD API.
Get uplink_interface_mac value.
Notes: MAC address of the host interface
This attribute is named `uplinkInterfaceMAC` in VSD API.
Get uplink_vport_name value.
Notes: Name of the uplink vport
This attribute is named `uplinkVPortName` in VSD API.
Get vn_id value.
Notes: VNID of the Shared Resource
This attribute is named `vnID` in VSD API.
Methods
Initializes a SharedNetworkResource instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> sharednetworkresource = NUSharedNetworkResource(id=u'xxxx-xxx-xxx-xxx', name=u'SharedNetworkResource') >>> sharednetworkresource = NUSharedNetworkResource(data=my_dict)
Add a child
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
Compare with another object
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
Get all genealogic ids
Returns: A list of all parent ids
Get genealogic types
Returns: Returns a list of all parent types
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
Get all attributes information
Returns: Returns a dictionnary containing attribute information
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
Get resource complete url
Get the resource url for the nurest_object type
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
Check if the current user owns the object
Get a new object with the given id
Returns: Returns a new instance with specified id
Return parent that matches a rest name
Register a children fetcher
Remove a child
Override this method to set object base url
Compare objects REST attributes
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
Update child
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
class NUSiteInfo
Represents a SiteInfo in the VSD
Notes: Remote Site info.
class NUSiteInfo(NURESTObject):
""" Represents a SiteInfo in the VSD
Notes:
Remote Site info.
"""
__rest_name__ = "site"
__resource_name__ = "sites"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a SiteInfo instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> siteinfo = NUSiteInfo(id=u'xxxx-xxx-xxx-xxx', name=u'SiteInfo')
>>> siteinfo = NUSiteInfo(data=my_dict)
"""
super(NUSiteInfo, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._address = None
self._description = None
self._site_identifier = None
self._xmpp_domain = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_identifier", remote_name="siteIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="xmpp_domain", remote_name="xmppDomain", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
name of the Remote Site.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
name of the Remote Site.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
unique fqdn/address of the remote site
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
unique fqdn/address of the remote site
"""
self._address = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Remote Site.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Remote Site.
"""
self._description = value
@property
def site_identifier(self):
""" Get site_identifier value.
Notes:
unique identifier of the remote site
This attribute is named `siteIdentifier` in VSD API.
"""
return self._site_identifier
@site_identifier.setter
def site_identifier(self, value):
""" Set site_identifier value.
Notes:
unique identifier of the remote site
This attribute is named `siteIdentifier` in VSD API.
"""
self._site_identifier = value
@property
def xmpp_domain(self):
""" Get xmpp_domain value.
Notes:
unique xmpp domain name of the remote site
This attribute is named `xmppDomain` in VSD API.
"""
return self._xmpp_domain
@xmpp_domain.setter
def xmpp_domain(self, value):
""" Set xmpp_domain value.
Notes:
unique xmpp domain name of the remote site
This attribute is named `xmppDomain` in VSD API.
"""
self._xmpp_domain = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUSiteInfo
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: unique fqdn/address of the remote site
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the Remote Site.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: name of the Remote Site.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var site_identifier
Get site_identifier value.
Notes: unique identifier of the remote site
This attribute is named `siteIdentifier` in VSD API.
var xmpp_domain
Get xmpp_domain value.
Notes: unique xmpp domain name of the remote site
This attribute is named `xmppDomain` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a SiteInfo instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> siteinfo = NUSiteInfo(id=u'xxxx-xxx-xxx-xxx', name=u'SiteInfo') >>> siteinfo = NUSiteInfo(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a SiteInfo instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> siteinfo = NUSiteInfo(id=u'xxxx-xxx-xxx-xxx', name=u'SiteInfo')
>>> siteinfo = NUSiteInfo(data=my_dict)
"""
super(NUSiteInfo, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._address = None
self._description = None
self._site_identifier = None
self._xmpp_domain = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_identifier", remote_name="siteIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="xmpp_domain", remote_name="xmppDomain", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUStaticRoute
Represents a StaticRoute in the VSD
Notes: Static routes allow end users to define how traffic is routed through the dVRS in addition to the routes learned by VSC through VM activation. By using static routes, end users can define for example that all traffic with a destination address towards a specific subnet must be forwarded to a specific VM attached in the dVRS and this VM could be a firewall.
class NUStaticRoute(NURESTObject):
""" Represents a StaticRoute in the VSD
Notes:
Static routes allow end users to define how traffic is routed through the dVRS in addition to the routes learned by VSC through VM activation. By using static routes, end users can define for example that all traffic with a destination address towards a specific subnet must be forwarded to a specific VM attached in the dVRS and this VM could be a firewall.
"""
__rest_name__ = "staticroute"
__resource_name__ = "staticroutes"
## Constants
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a StaticRoute instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> staticroute = NUStaticRoute(id=u'xxxx-xxx-xxx-xxx', name=u'StaticRoute')
>>> staticroute = NUStaticRoute(data=my_dict)
"""
super(NUStaticRoute, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._last_updated_by = None
self._address = None
self._netmask = None
self._next_hop_ip = None
self._entity_scope = None
self._route_distinguisher = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="next_hop_ip", remote_name="nextHopIp", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the route
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the route
"""
self._address = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask associated with the route
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask associated with the route
"""
self._netmask = value
@property
def next_hop_ip(self):
""" Get next_hop_ip value.
Notes:
IP address of the next hop. This must be a VM attached to the dVRS
This attribute is named `nextHopIp` in VSD API.
"""
return self._next_hop_ip
@next_hop_ip.setter
def next_hop_ip(self, value):
""" Set next_hop_ip value.
Notes:
IP address of the next hop. This must be a VM attached to the dVRS
This attribute is named `nextHopIp` in VSD API.
"""
self._next_hop_ip = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def route_distinguisher(self):
""" Get route_distinguisher value.
Notes:
Route distinguisher associated with the nexthop. System generates this identifier automatically
This attribute is named `routeDistinguisher` in VSD API.
"""
return self._route_distinguisher
@route_distinguisher.setter
def route_distinguisher(self, value):
""" Set route_distinguisher value.
Notes:
Route distinguisher associated with the nexthop. System generates this identifier automatically
This attribute is named `routeDistinguisher` in VSD API.
"""
self._route_distinguisher = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUStaticRoute
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the route
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6
This attribute is named `IPType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var netmask
Get netmask value.
Notes: Netmask associated with the route
var next_hop_ip
Get next_hop_ip value.
Notes: IP address of the next hop. This must be a VM attached to the dVRS
This attribute is named `nextHopIp` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var route_distinguisher
Get route_distinguisher value.
Notes: Route distinguisher associated with the nexthop. System generates this identifier automatically
This attribute is named `routeDistinguisher` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a StaticRoute instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> staticroute = NUStaticRoute(id=u'xxxx-xxx-xxx-xxx', name=u'StaticRoute') >>> staticroute = NUStaticRoute(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a StaticRoute instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> staticroute = NUStaticRoute(id=u'xxxx-xxx-xxx-xxx', name=u'StaticRoute')
>>> staticroute = NUStaticRoute(data=my_dict)
"""
super(NUStaticRoute, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._last_updated_by = None
self._address = None
self._netmask = None
self._next_hop_ip = None
self._entity_scope = None
self._route_distinguisher = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="next_hop_ip", remote_name="nextHopIp", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUStatistics
Represents a Statistics in the VSD
Notes: Retrieves the statistics for a particular domain, zone, subnet, or VM.
class NUStatistics(NURESTObject):
""" Represents a Statistics in the VSD
Notes:
Retrieves the statistics for a particular domain, zone, subnet, or VM.
"""
__rest_name__ = "statistics"
__resource_name__ = "statistics"
def __init__(self, **kwargs):
""" Initializes a Statistics instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> statistics = NUStatistics(id=u'xxxx-xxx-xxx-xxx', name=u'Statistics')
>>> statistics = NUStatistics(data=my_dict)
"""
super(NUStatistics, self).__init__()
# Read/Write Attributes
self._version = None
self._end_time = None
self._start_time = None
self._stats_data = None
self._number_of_data_points = None
self.expose_attribute(local_name="version", remote_name="version", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="end_time", remote_name="endTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="start_time", remote_name="startTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_data", remote_name="statsData", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_data_points", remote_name="numberOfDataPoints", attribute_type=int, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def version(self):
""" Get version value.
Notes:
Version of this Sequence number.
"""
return self._version
@version.setter
def version(self, value):
""" Set version value.
Notes:
Version of this Sequence number.
"""
self._version = value
@property
def end_time(self):
""" Get end_time value.
Notes:
End time for the statistics to be retrieved
This attribute is named `endTime` in VSD API.
"""
return self._end_time
@end_time.setter
def end_time(self, value):
""" Set end_time value.
Notes:
End time for the statistics to be retrieved
This attribute is named `endTime` in VSD API.
"""
self._end_time = value
@property
def start_time(self):
""" Get start_time value.
Notes:
Start time for the statistics to be retrieved
This attribute is named `startTime` in VSD API.
"""
return self._start_time
@start_time.setter
def start_time(self, value):
""" Set start_time value.
Notes:
Start time for the statistics to be retrieved
This attribute is named `startTime` in VSD API.
"""
self._start_time = value
@property
def stats_data(self):
""" Get stats_data value.
Notes:
Map<TCAMetric, Long[]> TCAMetric is an Enum. Possible values are packets_in, bytes_in, packets_in_dropped, packets_in_errors, packets_out, bytes_out, packets_out_dropped, packets_out_errors, packets_dropped_rate_limit
This attribute is named `statsData` in VSD API.
"""
return self._stats_data
@stats_data.setter
def stats_data(self, value):
""" Set stats_data value.
Notes:
Map<TCAMetric, Long[]> TCAMetric is an Enum. Possible values are packets_in, bytes_in, packets_in_dropped, packets_in_errors, packets_out, bytes_out, packets_out_dropped, packets_out_errors, packets_dropped_rate_limit
This attribute is named `statsData` in VSD API.
"""
self._stats_data = value
@property
def number_of_data_points(self):
""" Get number_of_data_points value.
Notes:
Number of data points between start time and end time
This attribute is named `numberOfDataPoints` in VSD API.
"""
return self._number_of_data_points
@number_of_data_points.setter
def number_of_data_points(self, value):
""" Set number_of_data_points value.
Notes:
Number of data points between start time and end time
This attribute is named `numberOfDataPoints` in VSD API.
"""
self._number_of_data_points = value
Ancestors (in MRO)
- NUStatistics
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var end_time
Get end_time value.
Notes: End time for the statistics to be retrieved
This attribute is named `endTime` in VSD API.
var errors
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var number_of_data_points
Get number_of_data_points value.
Notes: Number of data points between start time and end time
This attribute is named `numberOfDataPoints` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var start_time
Get start_time value.
Notes: Start time for the statistics to be retrieved
This attribute is named `startTime` in VSD API.
var stats_data
Get stats_data value.
Notes: Map<TCAMetric, Long[]> TCAMetric is an Enum. Possible values are packets_in, bytes_in, packets_in_dropped, packets_in_errors, packets_out, bytes_out, packets_out_dropped, packets_out_errors, packets_dropped_rate_limit
This attribute is named `statsData` in VSD API.
var version
Get version value.
Notes: Version of this Sequence number.
Methods
def __init__(
self, **kwargs)
Initializes a Statistics instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> statistics = NUStatistics(id=u'xxxx-xxx-xxx-xxx', name=u'Statistics') >>> statistics = NUStatistics(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Statistics instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> statistics = NUStatistics(id=u'xxxx-xxx-xxx-xxx', name=u'Statistics')
>>> statistics = NUStatistics(data=my_dict)
"""
super(NUStatistics, self).__init__()
# Read/Write Attributes
self._version = None
self._end_time = None
self._start_time = None
self._stats_data = None
self._number_of_data_points = None
self.expose_attribute(local_name="version", remote_name="version", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="end_time", remote_name="endTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="start_time", remote_name="startTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_data", remote_name="statsData", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_data_points", remote_name="numberOfDataPoints", attribute_type=int, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUStatisticsPolicy
Represents a StatisticsPolicy in the VSD
Notes: Defines the frequency of statistics collection associated with an object.
class NUStatisticsPolicy(NURESTObject):
""" Represents a StatisticsPolicy in the VSD
Notes:
Defines the frequency of statistics collection associated with an object.
"""
__rest_name__ = "statisticspolicy"
__resource_name__ = "statisticspolicies"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a StatisticsPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> statisticspolicy = NUStatisticsPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'StatisticsPolicy')
>>> statisticspolicy = NUStatisticsPolicy(data=my_dict)
"""
super(NUStatisticsPolicy, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._data_collection_frequency = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_collection_frequency", remote_name="dataCollectionFrequency", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of statistics policy
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of statistics policy
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data_collection_frequency(self):
""" Get data_collection_frequency value.
Notes:
How frequent to collect statistics in seconds
This attribute is named `dataCollectionFrequency` in VSD API.
"""
return self._data_collection_frequency
@data_collection_frequency.setter
def data_collection_frequency(self, value):
""" Set data_collection_frequency value.
Notes:
How frequent to collect statistics in seconds
This attribute is named `dataCollectionFrequency` in VSD API.
"""
self._data_collection_frequency = value
@property
def description(self):
""" Get description value.
Notes:
A description of the statistics policy
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the statistics policy
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUStatisticsPolicy
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var data_collection_frequency
Get data_collection_frequency value.
Notes: How frequent to collect statistics in seconds
This attribute is named `dataCollectionFrequency` in VSD API.
var description
Get description value.
Notes: A description of the statistics policy
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of statistics policy
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a StatisticsPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> statisticspolicy = NUStatisticsPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'StatisticsPolicy') >>> statisticspolicy = NUStatisticsPolicy(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a StatisticsPolicy instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> statisticspolicy = NUStatisticsPolicy(id=u'xxxx-xxx-xxx-xxx', name=u'StatisticsPolicy')
>>> statisticspolicy = NUStatisticsPolicy(data=my_dict)
"""
super(NUStatisticsPolicy, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._data_collection_frequency = None
self._description = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_collection_frequency", remote_name="dataCollectionFrequency", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUStatsCollectorInfo
Represents a StatsCollectorInfo in the VSD
Notes: Identifies the IP address of the stats collector entity that must be used.
class NUStatsCollectorInfo(NURESTObject):
""" Represents a StatsCollectorInfo in the VSD
Notes:
Identifies the IP address of the stats collector entity that must be used.
"""
__rest_name__ = "statisticscollector"
__resource_name__ = "statisticscollector"
## Constants
CONST_ADDRESS_TYPE_FQDN = "fqdn"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ADDRESS_TYPE_IP = "ip"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a StatsCollectorInfo instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> statscollectorinfo = NUStatsCollectorInfo(id=u'xxxx-xxx-xxx-xxx', name=u'StatsCollectorInfo')
>>> statscollectorinfo = NUStatsCollectorInfo(data=my_dict)
"""
super(NUStatsCollectorInfo, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._address_type = None
self._entity_scope = None
self._port = None
self._ip_address = None
self._proto_buf_port = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_type", remote_name="addressType", attribute_type=str, is_required=False, is_unique=False, choices=[u'fqdn', u'ip'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port", remote_name="port", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="ipAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="proto_buf_port", remote_name="protoBufPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address_type(self):
""" Get address_type value.
Notes:
Type for stats collector address Possible values are ip, fqdn, .
This attribute is named `addressType` in VSD API.
"""
return self._address_type
@address_type.setter
def address_type(self, value):
""" Set address_type value.
Notes:
Type for stats collector address Possible values are ip, fqdn, .
This attribute is named `addressType` in VSD API.
"""
self._address_type = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port(self):
""" Get port value.
Notes:
Port(s) of the stats collector process
"""
return self._port
@port.setter
def port(self, value):
""" Set port value.
Notes:
Port(s) of the stats collector process
"""
self._port = value
@property
def ip_address(self):
""" Get ip_address value.
Notes:
IP address(es) of the stats collector process
This attribute is named `ipAddress` in VSD API.
"""
return self._ip_address
@ip_address.setter
def ip_address(self, value):
""" Set ip_address value.
Notes:
IP address(es) of the stats collector process
This attribute is named `ipAddress` in VSD API.
"""
self._ip_address = value
@property
def proto_buf_port(self):
""" Get proto_buf_port value.
Notes:
Protobuf Port(s) of the stats collector process
This attribute is named `protoBufPort` in VSD API.
"""
return self._proto_buf_port
@proto_buf_port.setter
def proto_buf_port(self, value):
""" Set proto_buf_port value.
Notes:
Protobuf Port(s) of the stats collector process
This attribute is named `protoBufPort` in VSD API.
"""
self._proto_buf_port = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUStatsCollectorInfo
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ADDRESS_TYPE_FQDN
var CONST_ADDRESS_TYPE_IP
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var address_type
Get address_type value.
Notes: Type for stats collector address Possible values are ip, fqdn, .
This attribute is named `addressType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ip_address
Get ip_address value.
Notes: IP address(es) of the stats collector process
This attribute is named `ipAddress` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var port
Get port value.
Notes: Port(s) of the stats collector process
var proto_buf_port
Get proto_buf_port value.
Notes: Protobuf Port(s) of the stats collector process
This attribute is named `protoBufPort` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a StatsCollectorInfo instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> statscollectorinfo = NUStatsCollectorInfo(id=u'xxxx-xxx-xxx-xxx', name=u'StatsCollectorInfo') >>> statscollectorinfo = NUStatsCollectorInfo(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a StatsCollectorInfo instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> statscollectorinfo = NUStatsCollectorInfo(id=u'xxxx-xxx-xxx-xxx', name=u'StatsCollectorInfo')
>>> statscollectorinfo = NUStatsCollectorInfo(data=my_dict)
"""
super(NUStatsCollectorInfo, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._address_type = None
self._entity_scope = None
self._port = None
self._ip_address = None
self._proto_buf_port = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_type", remote_name="addressType", attribute_type=str, is_required=False, is_unique=False, choices=[u'fqdn', u'ip'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port", remote_name="port", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="ipAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="proto_buf_port", remote_name="protoBufPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUSubnet
Represents a Subnet in the VSD
Notes: This is the definition of a subnet associated with a zone.
class NUSubnet(NURESTObject):
""" Represents a Subnet in the VSD
Notes:
This is the definition of a subnet associated with a zone.
"""
__rest_name__ = "subnet"
__resource_name__ = "subnets"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_PAT_ENABLED_INHERITED = "INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_UNDERLAY_ENABLED_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_PAT_ENABLED_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_UNDERLAY_ENABLED_DISABLED = "DISABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_MAINTENANCE_MODE_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ENCRYPTION_INHERITED = "INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_UNDERLAY_ENABLED_INHERITED = "INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_MULTICAST_INHERITED = "INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_PAT_ENABLED_DISABLED = "DISABLED"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_MAINTENANCE_MODE_DISABLED = "DISABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_MAINTENANCE_MODE_ENABLED_INHERITED = "ENABLED_INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
def __init__(self, **kwargs):
""" Initializes a Subnet instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> subnet = NUSubnet(id=u'xxxx-xxx-xxx-xxx', name=u'Subnet')
>>> subnet = NUSubnet(data=my_dict)
"""
super(NUSubnet, self).__init__()
# Read/Write Attributes
self._pat_enabled = None
self._ip_type = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._gateway_mac_address = None
self._address = None
self._template_id = None
self._service_id = None
self._description = None
self._netmask = None
self._vn_id = None
self._encryption = None
self._underlay_enabled = None
self._entity_scope = None
self._policy_group_id = None
self._route_distinguisher = None
self._route_target = None
self._split_subnet = None
self._proxy_arp = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_multicast_channel_map_id = None
self._associated_shared_network_resource_id = None
self._public = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="pat_enabled", remote_name="PATEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_mac_address", remote_name="gatewayMACAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id", remote_name="serviceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vn_id", remote_name="vnId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="underlay_enabled", remote_name="underlayEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_group_id", remote_name="policyGroupID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_target", remote_name="routeTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="split_subnet", remote_name="splitSubnet", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="proxy_arp", remote_name="proxyARP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_shared_network_resource_id", remote_name="associatedSharedNetworkResourceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public", remote_name="public", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_resyncs = NUVMResyncsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.virtual_ips = NUVirtualIPsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ip_reservations = NUIPReservationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def pat_enabled(self):
""" Get pat_enabled value.
Notes:
None
This attribute is named `PATEnabled` in VSD API.
"""
return self._pat_enabled
@pat_enabled.setter
def pat_enabled(self, value):
""" Set pat_enabled value.
Notes:
None
This attribute is named `PATEnabled` in VSD API.
"""
self._pat_enabled = value
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def maintenance_mode(self):
""" Get maintenance_mode value.
Notes:
maintenanceMode is an enum that indicates if the SubNetwork is accepting VM activation requests.
This attribute is named `maintenanceMode` in VSD API.
"""
return self._maintenance_mode
@maintenance_mode.setter
def maintenance_mode(self, value):
""" Set maintenance_mode value.
Notes:
maintenanceMode is an enum that indicates if the SubNetwork is accepting VM activation requests.
This attribute is named `maintenanceMode` in VSD API.
"""
self._maintenance_mode = value
@property
def name(self):
""" Get name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
The IP address of the gateway of this subnet
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
The IP address of the gateway of this subnet
"""
self._gateway = value
@property
def gateway_mac_address(self):
""" Get gateway_mac_address value.
Notes:
None
This attribute is named `gatewayMACAddress` in VSD API.
"""
return self._gateway_mac_address
@gateway_mac_address.setter
def gateway_mac_address(self, value):
""" Set gateway_mac_address value.
Notes:
None
This attribute is named `gatewayMACAddress` in VSD API.
"""
self._gateway_mac_address = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
self._address = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the subnet template that this subnet object was derived from
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the subnet template that this subnet object was derived from
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def service_id(self):
""" Get service_id value.
Notes:
The service ID used by the VSCs to identify this subnet
This attribute is named `serviceID` in VSD API.
"""
return self._service_id
@service_id.setter
def service_id(self, value):
""" Set service_id value.
Notes:
The service ID used by the VSCs to identify this subnet
This attribute is named `serviceID` in VSD API.
"""
self._service_id = value
@property
def description(self):
""" Get description value.
Notes:
A description field provided by the user that identifies the subnet
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description field provided by the user that identifies the subnet
"""
self._description = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet defined
"""
self._netmask = value
@property
def vn_id(self):
""" Get vn_id value.
Notes:
Current Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `vnId` in VSD API.
"""
return self._vn_id
@vn_id.setter
def vn_id(self, value):
""" Set vn_id value.
Notes:
Current Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `vnId` in VSD API.
"""
self._vn_id = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether or not IPSEC is enabled.
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether or not IPSEC is enabled.
"""
self._encryption = value
@property
def underlay_enabled(self):
""" Get underlay_enabled value.
Notes:
Indicates whether UNDERLAY is enabled for the subnets in this domain
This attribute is named `underlayEnabled` in VSD API.
"""
return self._underlay_enabled
@underlay_enabled.setter
def underlay_enabled(self, value):
""" Set underlay_enabled value.
Notes:
Indicates whether UNDERLAY is enabled for the subnets in this domain
This attribute is named `underlayEnabled` in VSD API.
"""
self._underlay_enabled = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_group_id(self):
""" Get policy_group_id value.
Notes:
PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
"""
return self._policy_group_id
@policy_group_id.setter
def policy_group_id(self, value):
""" Set policy_group_id value.
Notes:
PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
"""
self._policy_group_id = value
@property
def route_distinguisher(self):
""" Get route_distinguisher value.
Notes:
The Route Distinguisher value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeDistinguisher` in VSD API.
"""
return self._route_distinguisher
@route_distinguisher.setter
def route_distinguisher(self, value):
""" Set route_distinguisher value.
Notes:
The Route Distinguisher value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeDistinguisher` in VSD API.
"""
self._route_distinguisher = value
@property
def route_target(self):
""" Get route_target value.
Notes:
The Route Target value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeTarget` in VSD API.
"""
return self._route_target
@route_target.setter
def route_target(self, value):
""" Set route_target value.
Notes:
The Route Target value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeTarget` in VSD API.
"""
self._route_target = value
@property
def split_subnet(self):
""" Get split_subnet value.
Notes:
Need to add correct description
This attribute is named `splitSubnet` in VSD API.
"""
return self._split_subnet
@split_subnet.setter
def split_subnet(self, value):
""" Set split_subnet value.
Notes:
Need to add correct description
This attribute is named `splitSubnet` in VSD API.
"""
self._split_subnet = value
@property
def proxy_arp(self):
""" Get proxy_arp value.
Notes:
when set VRS will act as ARP Proxy
This attribute is named `proxyARP` in VSD API.
"""
return self._proxy_arp
@proxy_arp.setter
def proxy_arp(self, value):
""" Set proxy_arp value.
Notes:
when set VRS will act as ARP Proxy
This attribute is named `proxyARP` in VSD API.
"""
self._proxy_arp = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID.
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID.
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID.
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID.
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type. Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type. Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this Subnet/Subnet Template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this Subnet/Subnet Template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def associated_shared_network_resource_id(self):
""" Get associated_shared_network_resource_id value.
Notes:
The ID of public subnet that is associated with this subnet
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
"""
return self._associated_shared_network_resource_id
@associated_shared_network_resource_id.setter
def associated_shared_network_resource_id(self, value):
""" Set associated_shared_network_resource_id value.
Notes:
The ID of public subnet that is associated with this subnet
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
"""
self._associated_shared_network_resource_id = value
@property
def public(self):
""" Get public value.
Notes:
when set to true means public subnet under a public zone
"""
return self._public
@public.setter
def public(self, value):
""" Set public value.
Notes:
when set to true means public subnet under a public zone
"""
self._public = value
@property
def multicast(self):
""" Get multicast value.
Notes:
multicast is enum that indicates multicast policy on Subnet/Subnet Template.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
multicast is enum that indicates multicast policy on Subnet/Subnet Template.
"""
self._multicast = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUSubnet
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENCRYPTION_INHERITED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var CONST_MAINTENANCE_MODE_DISABLED
var CONST_MAINTENANCE_MODE_ENABLED
var CONST_MAINTENANCE_MODE_ENABLED_INHERITED
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var CONST_PAT_ENABLED_DISABLED
var CONST_PAT_ENABLED_ENABLED
var CONST_PAT_ENABLED_INHERITED
var CONST_UNDERLAY_ENABLED_DISABLED
var CONST_UNDERLAY_ENABLED_ENABLED
var CONST_UNDERLAY_ENABLED_INHERITED
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
var address_ranges
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID.
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID.
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type. Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this Subnet/Subnet Template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
Get associated_shared_network_resource_id value.
Notes: The ID of public subnet that is associated with this subnet
This attribute is named `associatedSharedNetworkResourceID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description field provided by the user that identifies the subnet
var dhcp_options
var encryption
Get encryption value.
Notes: Determines whether or not IPSEC is enabled.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: The IP address of the gateway of this subnet
var gateway_mac_address
Get gateway_mac_address value.
Notes: None
This attribute is named `gatewayMACAddress` in VSD API.
var global_metadatas
var id
Get object id
var ip_reservations
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6
This attribute is named `IPType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var maintenance_mode
Get maintenance_mode value.
Notes: maintenanceMode is an enum that indicates if the SubNetwork is accepting VM activation requests.
This attribute is named `maintenanceMode` in VSD API.
var metadatas
var multicast
Get multicast value.
Notes: multicast is enum that indicates multicast policy on Subnet/Subnet Template.
var name
Get name value.
Notes: Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the subnet defined
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var pat_enabled
Get pat_enabled value.
Notes: None
This attribute is named `PATEnabled` in VSD API.
var policy_group_id
Get policy_group_id value.
Notes: PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
var proxy_arp
Get proxy_arp value.
Notes: when set VRS will act as ARP Proxy
This attribute is named `proxyARP` in VSD API.
var public
Get public value.
Notes: when set to true means public subnet under a public zone
var qoss
var route_distinguisher
Get route_distinguisher value.
Notes: The Route Distinguisher value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeDistinguisher` in VSD API.
var route_target
Get route_target value.
Notes: The Route Target value assigned by VSD for this subnet that is used by the BGP-EVPN protocol in VSC
This attribute is named `routeTarget` in VSD API.
var service_id
Get service_id value.
Notes: The service ID used by the VSCs to identify this subnet
This attribute is named `serviceID` in VSD API.
var split_subnet
Get split_subnet value.
Notes: Need to add correct description
This attribute is named `splitSubnet` in VSD API.
var statistics
var statistics_policies
var tcas
var template_id
Get template_id value.
Notes: The ID of the subnet template that this subnet object was derived from
This attribute is named `templateID` in VSD API.
var underlay_enabled
Get underlay_enabled value.
Notes: Indicates whether UNDERLAY is enabled for the subnets in this domain
This attribute is named `underlayEnabled` in VSD API.
var virtual_ips
var vm_interfaces
var vm_resyncs
var vms
var vn_id
Get vn_id value.
Notes: Current Network's globally unique VXLAN network identifier generated by VSD
This attribute is named `vnId` in VSD API.
var vports
Methods
def __init__(
self, **kwargs)
Initializes a Subnet instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> subnet = NUSubnet(id=u'xxxx-xxx-xxx-xxx', name=u'Subnet') >>> subnet = NUSubnet(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Subnet instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> subnet = NUSubnet(id=u'xxxx-xxx-xxx-xxx', name=u'Subnet')
>>> subnet = NUSubnet(data=my_dict)
"""
super(NUSubnet, self).__init__()
# Read/Write Attributes
self._pat_enabled = None
self._ip_type = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._gateway_mac_address = None
self._address = None
self._template_id = None
self._service_id = None
self._description = None
self._netmask = None
self._vn_id = None
self._encryption = None
self._underlay_enabled = None
self._entity_scope = None
self._policy_group_id = None
self._route_distinguisher = None
self._route_target = None
self._split_subnet = None
self._proxy_arp = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_multicast_channel_map_id = None
self._associated_shared_network_resource_id = None
self._public = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="pat_enabled", remote_name="PATEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_mac_address", remote_name="gatewayMACAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id", remote_name="serviceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vn_id", remote_name="vnId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="underlay_enabled", remote_name="underlayEnabled", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_group_id", remote_name="policyGroupID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="route_target", remote_name="routeTarget", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="split_subnet", remote_name="splitSubnet", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="proxy_arp", remote_name="proxyARP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_shared_network_resource_id", remote_name="associatedSharedNetworkResourceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public", remote_name="public", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_resyncs = NUVMResyncsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.virtual_ips = NUVirtualIPsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.ip_reservations = NUIPReservationsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUSubnetTemplate
Represents a SubnetTemplate in the VSD
Notes: As domain and zone objects, subnet objects are created in VSD as derived by templates. This object describes the subnet template.
class NUSubnetTemplate(NURESTObject):
""" Represents a SubnetTemplate in the VSD
Notes:
As domain and zone objects, subnet objects are created in VSD as derived by templates. This object describes the subnet template.
"""
__rest_name__ = "subnettemplate"
__resource_name__ = "subnettemplates"
## Constants
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_ENCRYPTION_INHERITED = "INHERITED"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_MULTICAST_INHERITED = "INHERITED"
def __init__(self, **kwargs):
""" Initializes a SubnetTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> subnettemplate = NUSubnetTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'SubnetTemplate')
>>> subnettemplate = NUSubnetTemplate(data=my_dict)
"""
super(NUSubnetTemplate, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._split_subnet = None
self._proxy_arp = None
self._associated_multicast_channel_map_id = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="split_subnet", remote_name="splitSubnet", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="proxy_arp", remote_name="proxyARP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def name(self):
""" Get name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
The IP address of the gateway of this subnet
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
The IP address of the gateway of this subnet
"""
self._gateway = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
self._address = value
@property
def description(self):
""" Get description value.
Notes:
A description field provided by the user that identifies the subnet
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description field provided by the user that identifies the subnet
"""
self._description = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet defined
"""
self._netmask = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether or not IPSEC is enabled. Possible values are INHERITED, ENABLED, DISABLED, .
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether or not IPSEC is enabled. Possible values are INHERITED, ENABLED, DISABLED, .
"""
self._encryption = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def split_subnet(self):
""" Get split_subnet value.
Notes:
Need to add correct description
This attribute is named `splitSubnet` in VSD API.
"""
return self._split_subnet
@split_subnet.setter
def split_subnet(self, value):
""" Set split_subnet value.
Notes:
Need to add correct description
This attribute is named `splitSubnet` in VSD API.
"""
self._split_subnet = value
@property
def proxy_arp(self):
""" Get proxy_arp value.
Notes:
when set VRS will act as ARP Proxy
This attribute is named `proxyARP` in VSD API.
"""
return self._proxy_arp
@proxy_arp.setter
def proxy_arp(self, value):
""" Set proxy_arp value.
Notes:
when set VRS will act as ARP Proxy
This attribute is named `proxyARP` in VSD API.
"""
self._proxy_arp = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this Subnet/Subnet Template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this Subnet/Subnet Template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def multicast(self):
""" Get multicast value.
Notes:
Indicates multicast policy on Subnet/Subnet Template.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
Indicates multicast policy on Subnet/Subnet Template.
"""
self._multicast = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUSubnetTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENCRYPTION_INHERITED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
var address_ranges
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this Subnet/Subnet Template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description field provided by the user that identifies the subnet
var encryption
Get encryption value.
Notes: Determines whether or not IPSEC is enabled. Possible values are INHERITED, ENABLED, DISABLED, .
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: The IP address of the gateway of this subnet
var global_metadatas
var id
Get object id
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6
This attribute is named `IPType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var multicast
Get multicast value.
Notes: Indicates multicast policy on Subnet/Subnet Template.
var name
Get name value.
Notes: Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the subnet defined
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var proxy_arp
Get proxy_arp value.
Notes: when set VRS will act as ARP Proxy
This attribute is named `proxyARP` in VSD API.
var qoss
var split_subnet
Get split_subnet value.
Notes: Need to add correct description
This attribute is named `splitSubnet` in VSD API.
var subnets
Methods
def __init__(
self, **kwargs)
Initializes a SubnetTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> subnettemplate = NUSubnetTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'SubnetTemplate') >>> subnettemplate = NUSubnetTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a SubnetTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> subnettemplate = NUSubnetTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'SubnetTemplate')
>>> subnettemplate = NUSubnetTemplate(data=my_dict)
"""
super(NUSubnetTemplate, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._split_subnet = None
self._proxy_arp = None
self._associated_multicast_channel_map_id = None
self._multicast = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="split_subnet", remote_name="splitSubnet", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="proxy_arp", remote_name="proxyARP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.address_ranges = NUAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUSystemConfig
Represents a SystemConfig in the VSD
Notes: The system configuration which can be dynamically managed using rest api.
class NUSystemConfig(NURESTObject):
""" Represents a SystemConfig in the VSD
Notes:
The system configuration which can be dynamically managed using rest api.
"""
__rest_name__ = "systemconfig"
__resource_name__ = "systemconfigs"
## Constants
CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA512 = "HMAC_SHA512"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_MD5 = "HMAC_MD5"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_AES_256_CBC = "AES_256_CBC"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA = "SHA384withRSA"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA = "SHA512withRSA"
CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_ENCRYPTION_ALGORITHM_RSA_1024 = "RSA_1024"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA512 = "HMAC_SHA512"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA1 = "HMAC_SHA1"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA1 = "HMAC_SHA1"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_256_CBC = "AES_256_CBC"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA = "SHA384withRSA"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC = "TRIPLE_DES_CBC"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA256 = "HMAC_SHA256"
CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA = "SHA224withRSA"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_AES_128_CBC = "AES_128_CBC"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA256 = "HMAC_SHA256"
CONST_DOMAIN_TUNNEL_TYPE_VXLAN = "VXLAN"
CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA = "SHA1withRSA"
CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA = "SHA256withRSA"
CONST_DOMAIN_TUNNEL_TYPE_GRE = "GRE"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA = "SHA224withRSA"
CONST_DOMAIN_TUNNEL_TYPE_DC_DEFAULT = "DC_DEFAULT"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA = "SHA1withRSA"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA384 = "HMAC_SHA384"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA = "SHA256withRSA"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC = "TRIPLE_DES_CBC"
CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_AES_192_CBC = "AES_192_CBC"
CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_128_CBC = "AES_128_CBC"
CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA = "SHA512withRSA"
def __init__(self, **kwargs):
""" Initializes a SystemConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> systemconfig = NUSystemConfig(id=u'xxxx-xxx-xxx-xxx', name=u'SystemConfig')
>>> systemconfig = NUSystemConfig(data=my_dict)
"""
super(NUSystemConfig, self).__init__()
# Read/Write Attributes
self._acl_allow_origin = None
self._ecmp_count = None
self._ldap_sync_interval = None
self._ldap_trust_store_certifcate = None
self._ldap_trust_store_password = None
self._ad_gateway_purge_time = None
self._rd_lower_limit = None
self._rd_public_network_lower_limit = None
self._rd_public_network_upper_limit = None
self._rd_upper_limit = None
self._dhcp_option_size = None
self._vm_cache_size = None
self._vm_purge_time = None
self._vm_resync_deletion_wait_time = None
self._vm_resync_outstanding_interval = None
self._vm_unreachable_cleanup_time = None
self._vm_unreachable_time = None
self._vnid_lower_limit = None
self._vnid_public_network_lower_limit = None
self._vnid_public_network_upper_limit = None
self._vnid_upper_limit = None
self._api_key_renewal_interval = None
self._api_key_validity = None
self._lru_cache_size_per_subnet = None
self._vsc_on_same_version_as_vsd = None
self._vsd_read_only_mode = None
self._vsd_upgrade_is_complete = None
self._as_number = None
self._rt_lower_limit = None
self._rt_public_network_lower_limit = None
self._rt_public_network_upper_limit = None
self._rt_upper_limit = None
self._evpnbgp_community_tag_as_number = None
self._evpnbgp_community_tag_lower_limit = None
self._evpnbgp_community_tag_upper_limit = None
self._page_max_size = None
self._page_size = None
self._last_updated_by = None
self._max_failed_logins = None
self._max_response = None
self._reflexive_acl_timeout = None
self._service_id_upper_limit = None
self._key_server_monitor_enabled = None
self._key_server_vsd_data_synchronization_interval = None
self._offset_customer_id = None
self._offset_service_id = None
self._ejbca_nsg_certificate_profile = None
self._ejbca_nsg_end_entity_profile = None
self._ejbca_ocsp_responder_cn = None
self._ejbca_ocsp_responder_uri = None
self._ejbca_vsp_root_ca = None
self._alarms_max_per_object = None
self._elastic_cluster_name = None
self._inactive_timeout = None
self._entity_scope = None
self._domain_tunnel_type = None
self._post_processor_threads_count = None
self._group_key_default_sek_generation_interval = None
self._group_key_default_sek_lifetime = None
self._group_key_default_sek_payload_encryption_algorithm = None
self._group_key_default_sek_payload_signing_algorithm = None
self._group_key_default_seed_generation_interval = None
self._group_key_default_seed_lifetime = None
self._group_key_default_seed_payload_authentication_algorithm = None
self._group_key_default_seed_payload_encryption_algorithm = None
self._group_key_default_seed_payload_signing_algorithm = None
self._group_key_default_traffic_authentication_algorithm = None
self._group_key_default_traffic_encryption_algorithm = None
self._group_key_default_traffic_encryption_key_lifetime = None
self._group_key_generation_interval_on_forced_re_key = None
self._group_key_generation_interval_on_revoke = None
self._group_key_minimum_sek_generation_interval = None
self._group_key_minimum_sek_lifetime = None
self._group_key_minimum_seed_generation_interval = None
self._group_key_minimum_seed_lifetime = None
self._group_key_minimum_traffic_encryption_key_lifetime = None
self._nsg_bootstrap_endpoint = None
self._nsg_config_endpoint = None
self._nsg_local_ui_url = None
self._esi_id = None
self._stack_trace_enabled = None
self._static_wan_service_purge_time = None
self._statistics_enabled = None
self._stats_collector_address = None
self._stats_collector_port = None
self._stats_collector_proto_buf_port = None
self._stats_max_data_points = None
self._stats_min_duration = None
self._stats_number_of_data_points = None
self._stats_tsdb_server_address = None
self._subnet_resync_interval = None
self._subnet_resync_outstanding_interval = None
self._customer_id_upper_limit = None
self._customer_key = None
self._avatar_base_path = None
self._avatar_base_url = None
self._event_log_cleanup_interval = None
self._event_log_entry_max_age = None
self._event_processor_interval = None
self._event_processor_max_events_count = None
self._event_processor_timeout = None
self._two_factor_code_expiry = None
self._two_factor_code_length = None
self._two_factor_code_seed_length = None
self._external_id = None
self._dynamic_wan_service_diff_time = None
self._syslog_destination_host = None
self._syslog_destination_port = None
self._sysmon_cleanup_task_interval = None
self._sysmon_node_presence_timeout = None
self._sysmon_probe_response_timeout = None
self.expose_attribute(local_name="acl_allow_origin", remote_name="ACLAllowOrigin", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ecmp_count", remote_name="ECMPCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ldap_sync_interval", remote_name="LDAPSyncInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ldap_trust_store_certifcate", remote_name="LDAPTrustStoreCertifcate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ldap_trust_store_password", remote_name="LDAPTrustStorePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ad_gateway_purge_time", remote_name="ADGatewayPurgeTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_lower_limit", remote_name="RDLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_public_network_lower_limit", remote_name="RDPublicNetworkLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_public_network_upper_limit", remote_name="RDPublicNetworkUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_upper_limit", remote_name="RDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_option_size", remote_name="DHCPOptionSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_cache_size", remote_name="VMCacheSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_purge_time", remote_name="VMPurgeTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_resync_deletion_wait_time", remote_name="VMResyncDeletionWaitTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_resync_outstanding_interval", remote_name="VMResyncOutstandingInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_unreachable_cleanup_time", remote_name="VMUnreachableCleanupTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_unreachable_time", remote_name="VMUnreachableTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_lower_limit", remote_name="VNIDLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_public_network_lower_limit", remote_name="VNIDPublicNetworkLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_public_network_upper_limit", remote_name="VNIDPublicNetworkUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_upper_limit", remote_name="VNIDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="api_key_renewal_interval", remote_name="APIKeyRenewalInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="api_key_validity", remote_name="APIKeyValidity", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="lru_cache_size_per_subnet", remote_name="LRUCacheSizePerSubnet", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsc_on_same_version_as_vsd", remote_name="VSCOnSameVersionAsVSD", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsd_read_only_mode", remote_name="VSDReadOnlyMode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsd_upgrade_is_complete", remote_name="VSDUpgradeIsComplete", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="as_number", remote_name="ASNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_lower_limit", remote_name="RTLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_public_network_lower_limit", remote_name="RTPublicNetworkLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_public_network_upper_limit", remote_name="RTPublicNetworkUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_upper_limit", remote_name="RTUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="evpnbgp_community_tag_as_number", remote_name="EVPNBGPCommunityTagASNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="evpnbgp_community_tag_lower_limit", remote_name="EVPNBGPCommunityTagLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="evpnbgp_community_tag_upper_limit", remote_name="EVPNBGPCommunityTagUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="page_max_size", remote_name="pageMaxSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="page_size", remote_name="pageSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_failed_logins", remote_name="maxFailedLogins", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_response", remote_name="maxResponse", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive_acl_timeout", remote_name="reflexiveACLTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id_upper_limit", remote_name="serviceIDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="key_server_monitor_enabled", remote_name="keyServerMonitorEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="key_server_vsd_data_synchronization_interval", remote_name="keyServerVSDDataSynchronizationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="offset_customer_id", remote_name="offsetCustomerID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="offset_service_id", remote_name="offsetServiceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_nsg_certificate_profile", remote_name="ejbcaNSGCertificateProfile", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_nsg_end_entity_profile", remote_name="ejbcaNSGEndEntityProfile", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_ocsp_responder_cn", remote_name="ejbcaOCSPResponderCN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_ocsp_responder_uri", remote_name="ejbcaOCSPResponderURI", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_vsp_root_ca", remote_name="ejbcaVspRootCa", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="alarms_max_per_object", remote_name="alarmsMaxPerObject", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="elastic_cluster_name", remote_name="elasticClusterName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="inactive_timeout", remote_name="inactiveTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_tunnel_type", remote_name="domainTunnelType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC_DEFAULT', u'GRE', u'VXLAN'])
self.expose_attribute(local_name="post_processor_threads_count", remote_name="postProcessorThreadsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_sek_generation_interval", remote_name="groupKeyDefaultSEKGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_sek_lifetime", remote_name="groupKeyDefaultSEKLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_sek_payload_encryption_algorithm", remote_name="groupKeyDefaultSEKPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'RSA_1024'])
self.expose_attribute(local_name="group_key_default_sek_payload_signing_algorithm", remote_name="groupKeyDefaultSEKPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="group_key_default_seed_generation_interval", remote_name="groupKeyDefaultSeedGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_seed_lifetime", remote_name="groupKeyDefaultSeedLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_seed_payload_authentication_algorithm", remote_name="groupKeyDefaultSeedPayloadAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA512'])
self.expose_attribute(local_name="group_key_default_seed_payload_encryption_algorithm", remote_name="groupKeyDefaultSeedPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="group_key_default_seed_payload_signing_algorithm", remote_name="groupKeyDefaultSeedPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="group_key_default_traffic_authentication_algorithm", remote_name="groupKeyDefaultTrafficAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_MD5', u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA384', u'HMAC_SHA512'])
self.expose_attribute(local_name="group_key_default_traffic_encryption_algorithm", remote_name="groupKeyDefaultTrafficEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_192_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="group_key_default_traffic_encryption_key_lifetime", remote_name="groupKeyDefaultTrafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_generation_interval_on_forced_re_key", remote_name="groupKeyGenerationIntervalOnForcedReKey", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_generation_interval_on_revoke", remote_name="groupKeyGenerationIntervalOnRevoke", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_sek_generation_interval", remote_name="groupKeyMinimumSEKGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_sek_lifetime", remote_name="groupKeyMinimumSEKLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_seed_generation_interval", remote_name="groupKeyMinimumSeedGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_seed_lifetime", remote_name="groupKeyMinimumSeedLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_traffic_encryption_key_lifetime", remote_name="groupKeyMinimumTrafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nsg_bootstrap_endpoint", remote_name="nsgBootstrapEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nsg_config_endpoint", remote_name="nsgConfigEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nsg_local_ui_url", remote_name="nsgLocalUiUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="esi_id", remote_name="esiID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stack_trace_enabled", remote_name="stackTraceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_wan_service_purge_time", remote_name="staticWANServicePurgeTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="statistics_enabled", remote_name="statisticsEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_address", remote_name="statsCollectorAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_port", remote_name="statsCollectorPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_proto_buf_port", remote_name="statsCollectorProtoBufPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_max_data_points", remote_name="statsMaxDataPoints", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_min_duration", remote_name="statsMinDuration", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_number_of_data_points", remote_name="statsNumberOfDataPoints", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_tsdb_server_address", remote_name="statsTSDBServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subnet_resync_interval", remote_name="subnetResyncInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="subnet_resync_outstanding_interval", remote_name="subnetResyncOutstandingInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="customer_id_upper_limit", remote_name="customerIDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="customer_key", remote_name="customerKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_base_path", remote_name="avatarBasePath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_base_url", remote_name="avatarBaseURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_log_cleanup_interval", remote_name="eventLogCleanupInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_log_entry_max_age", remote_name="eventLogEntryMaxAge", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_processor_interval", remote_name="eventProcessorInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_processor_max_events_count", remote_name="eventProcessorMaxEventsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_processor_timeout", remote_name="eventProcessorTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="two_factor_code_expiry", remote_name="twoFactorCodeExpiry", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="two_factor_code_length", remote_name="twoFactorCodeLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="two_factor_code_seed_length", remote_name="twoFactorCodeSeedLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="dynamic_wan_service_diff_time", remote_name="dynamicWANServiceDiffTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="syslog_destination_host", remote_name="syslogDestinationHost", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="syslog_destination_port", remote_name="syslogDestinationPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sysmon_cleanup_task_interval", remote_name="sysmonCleanupTaskInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sysmon_node_presence_timeout", remote_name="sysmonNodePresenceTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sysmon_probe_response_timeout", remote_name="sysmonProbeResponseTimeout", attribute_type=int, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def acl_allow_origin(self):
""" Get acl_allow_origin value.
Notes:
Defines the domains allowed for access control list.
This attribute is named `ACLAllowOrigin` in VSD API.
"""
return self._acl_allow_origin
@acl_allow_origin.setter
def acl_allow_origin(self, value):
""" Set acl_allow_origin value.
Notes:
Defines the domains allowed for access control list.
This attribute is named `ACLAllowOrigin` in VSD API.
"""
self._acl_allow_origin = value
@property
def ecmp_count(self):
""" Get ecmp_count value.
Notes:
System Default Equal-cost multi-path routing count,Every Domain derives ECMP count from this value unless specifically set for the domain
This attribute is named `ECMPCount` in VSD API.
"""
return self._ecmp_count
@ecmp_count.setter
def ecmp_count(self, value):
""" Set ecmp_count value.
Notes:
System Default Equal-cost multi-path routing count,Every Domain derives ECMP count from this value unless specifically set for the domain
This attribute is named `ECMPCount` in VSD API.
"""
self._ecmp_count = value
@property
def ldap_sync_interval(self):
""" Get ldap_sync_interval value.
Notes:
LDAP Sync-Up task interval in seconds.
This attribute is named `LDAPSyncInterval` in VSD API.
"""
return self._ldap_sync_interval
@ldap_sync_interval.setter
def ldap_sync_interval(self, value):
""" Set ldap_sync_interval value.
Notes:
LDAP Sync-Up task interval in seconds.
This attribute is named `LDAPSyncInterval` in VSD API.
"""
self._ldap_sync_interval = value
@property
def ldap_trust_store_certifcate(self):
""" Get ldap_trust_store_certifcate value.
Notes:
Location of the truststore which is need to store LDAP server certificates. Default is cacerts located in java.home/lib/security/cacerts. Uncomment below setting if you need to use a different file
This attribute is named `LDAPTrustStoreCertifcate` in VSD API.
"""
return self._ldap_trust_store_certifcate
@ldap_trust_store_certifcate.setter
def ldap_trust_store_certifcate(self, value):
""" Set ldap_trust_store_certifcate value.
Notes:
Location of the truststore which is need to store LDAP server certificates. Default is cacerts located in java.home/lib/security/cacerts. Uncomment below setting if you need to use a different file
This attribute is named `LDAPTrustStoreCertifcate` in VSD API.
"""
self._ldap_trust_store_certifcate = value
@property
def ldap_trust_store_password(self):
""" Get ldap_trust_store_password value.
Notes:
Password to access the truststore. Uncomment below line to change its value.
This attribute is named `LDAPTrustStorePassword` in VSD API.
"""
return self._ldap_trust_store_password
@ldap_trust_store_password.setter
def ldap_trust_store_password(self, value):
""" Set ldap_trust_store_password value.
Notes:
Password to access the truststore. Uncomment below line to change its value.
This attribute is named `LDAPTrustStorePassword` in VSD API.
"""
self._ldap_trust_store_password = value
@property
def ad_gateway_purge_time(self):
""" Get ad_gateway_purge_time value.
Notes:
Timers in sec for undefined vms to be deleted(min =7200, max = 86400).
This attribute is named `ADGatewayPurgeTime` in VSD API.
"""
return self._ad_gateway_purge_time
@ad_gateway_purge_time.setter
def ad_gateway_purge_time(self, value):
""" Set ad_gateway_purge_time value.
Notes:
Timers in sec for undefined vms to be deleted(min =7200, max = 86400).
This attribute is named `ADGatewayPurgeTime` in VSD API.
"""
self._ad_gateway_purge_time = value
@property
def rd_lower_limit(self):
""" Get rd_lower_limit value.
Notes:
route distinguisher lower limit
This attribute is named `RDLowerLimit` in VSD API.
"""
return self._rd_lower_limit
@rd_lower_limit.setter
def rd_lower_limit(self, value):
""" Set rd_lower_limit value.
Notes:
route distinguisher lower limit
This attribute is named `RDLowerLimit` in VSD API.
"""
self._rd_lower_limit = value
@property
def rd_public_network_lower_limit(self):
""" Get rd_public_network_lower_limit value.
Notes:
route distinguisher public network lower limit
This attribute is named `RDPublicNetworkLowerLimit` in VSD API.
"""
return self._rd_public_network_lower_limit
@rd_public_network_lower_limit.setter
def rd_public_network_lower_limit(self, value):
""" Set rd_public_network_lower_limit value.
Notes:
route distinguisher public network lower limit
This attribute is named `RDPublicNetworkLowerLimit` in VSD API.
"""
self._rd_public_network_lower_limit = value
@property
def rd_public_network_upper_limit(self):
""" Get rd_public_network_upper_limit value.
Notes:
route distinguisher public network upper limit
This attribute is named `RDPublicNetworkUpperLimit` in VSD API.
"""
return self._rd_public_network_upper_limit
@rd_public_network_upper_limit.setter
def rd_public_network_upper_limit(self, value):
""" Set rd_public_network_upper_limit value.
Notes:
route distinguisher public network upper limit
This attribute is named `RDPublicNetworkUpperLimit` in VSD API.
"""
self._rd_public_network_upper_limit = value
@property
def rd_upper_limit(self):
""" Get rd_upper_limit value.
Notes:
route distinguisher upper limit
This attribute is named `RDUpperLimit` in VSD API.
"""
return self._rd_upper_limit
@rd_upper_limit.setter
def rd_upper_limit(self, value):
""" Set rd_upper_limit value.
Notes:
route distinguisher upper limit
This attribute is named `RDUpperLimit` in VSD API.
"""
self._rd_upper_limit = value
@property
def dhcp_option_size(self):
""" Get dhcp_option_size value.
Notes:
Defines total DHCP options that can be set on a domain.
This attribute is named `DHCPOptionSize` in VSD API.
"""
return self._dhcp_option_size
@dhcp_option_size.setter
def dhcp_option_size(self, value):
""" Set dhcp_option_size value.
Notes:
Defines total DHCP options that can be set on a domain.
This attribute is named `DHCPOptionSize` in VSD API.
"""
self._dhcp_option_size = value
@property
def vm_cache_size(self):
""" Get vm_cache_size value.
Notes:
LRU Map size for vm, this value has to set based on memory given to VSD jvm not finalized.
This attribute is named `VMCacheSize` in VSD API.
"""
return self._vm_cache_size
@vm_cache_size.setter
def vm_cache_size(self, value):
""" Set vm_cache_size value.
Notes:
LRU Map size for vm, this value has to set based on memory given to VSD jvm not finalized.
This attribute is named `VMCacheSize` in VSD API.
"""
self._vm_cache_size = value
@property
def vm_purge_time(self):
""" Get vm_purge_time value.
Notes:
Timers in sec for undefined vms to be deleted.
This attribute is named `VMPurgeTime` in VSD API.
"""
return self._vm_purge_time
@vm_purge_time.setter
def vm_purge_time(self, value):
""" Set vm_purge_time value.
Notes:
Timers in sec for undefined vms to be deleted.
This attribute is named `VMPurgeTime` in VSD API.
"""
self._vm_purge_time = value
@property
def vm_resync_deletion_wait_time(self):
""" Get vm_resync_deletion_wait_time value.
Notes:
After resync on vm , if no controller returns with a VM request with in the below timeframe then it will get deleted deletion wait time in minutes.
This attribute is named `VMResyncDeletionWaitTime` in VSD API.
"""
return self._vm_resync_deletion_wait_time
@vm_resync_deletion_wait_time.setter
def vm_resync_deletion_wait_time(self, value):
""" Set vm_resync_deletion_wait_time value.
Notes:
After resync on vm , if no controller returns with a VM request with in the below timeframe then it will get deleted deletion wait time in minutes.
This attribute is named `VMResyncDeletionWaitTime` in VSD API.
"""
self._vm_resync_deletion_wait_time = value
@property
def vm_resync_outstanding_interval(self):
""" Get vm_resync_outstanding_interval value.
Notes:
Outstanding VM resync interval (in secs). System wide value.
This attribute is named `VMResyncOutstandingInterval` in VSD API.
"""
return self._vm_resync_outstanding_interval
@vm_resync_outstanding_interval.setter
def vm_resync_outstanding_interval(self, value):
""" Set vm_resync_outstanding_interval value.
Notes:
Outstanding VM resync interval (in secs). System wide value.
This attribute is named `VMResyncOutstandingInterval` in VSD API.
"""
self._vm_resync_outstanding_interval = value
@property
def vm_unreachable_cleanup_time(self):
""" Get vm_unreachable_cleanup_time value.
Notes:
Timers in sec for unreachable VMs for cleanup.
This attribute is named `VMUnreachableCleanupTime` in VSD API.
"""
return self._vm_unreachable_cleanup_time
@vm_unreachable_cleanup_time.setter
def vm_unreachable_cleanup_time(self, value):
""" Set vm_unreachable_cleanup_time value.
Notes:
Timers in sec for unreachable VMs for cleanup.
This attribute is named `VMUnreachableCleanupTime` in VSD API.
"""
self._vm_unreachable_cleanup_time = value
@property
def vm_unreachable_time(self):
""" Get vm_unreachable_time value.
Notes:
Timers in sec for unreachable VMs.
This attribute is named `VMUnreachableTime` in VSD API.
"""
return self._vm_unreachable_time
@vm_unreachable_time.setter
def vm_unreachable_time(self, value):
""" Set vm_unreachable_time value.
Notes:
Timers in sec for unreachable VMs.
This attribute is named `VMUnreachableTime` in VSD API.
"""
self._vm_unreachable_time = value
@property
def vnid_lower_limit(self):
""" Get vnid_lower_limit value.
Notes:
Virtual network ID offset
This attribute is named `VNIDLowerLimit` in VSD API.
"""
return self._vnid_lower_limit
@vnid_lower_limit.setter
def vnid_lower_limit(self, value):
""" Set vnid_lower_limit value.
Notes:
Virtual network ID offset
This attribute is named `VNIDLowerLimit` in VSD API.
"""
self._vnid_lower_limit = value
@property
def vnid_public_network_lower_limit(self):
""" Get vnid_public_network_lower_limit value.
Notes:
Virtual network ID public network lower limit
This attribute is named `VNIDPublicNetworkLowerLimit` in VSD API.
"""
return self._vnid_public_network_lower_limit
@vnid_public_network_lower_limit.setter
def vnid_public_network_lower_limit(self, value):
""" Set vnid_public_network_lower_limit value.
Notes:
Virtual network ID public network lower limit
This attribute is named `VNIDPublicNetworkLowerLimit` in VSD API.
"""
self._vnid_public_network_lower_limit = value
@property
def vnid_public_network_upper_limit(self):
""" Get vnid_public_network_upper_limit value.
Notes:
Virtual network ID public network upper limit
This attribute is named `VNIDPublicNetworkUpperLimit` in VSD API.
"""
return self._vnid_public_network_upper_limit
@vnid_public_network_upper_limit.setter
def vnid_public_network_upper_limit(self, value):
""" Set vnid_public_network_upper_limit value.
Notes:
Virtual network ID public network upper limit
This attribute is named `VNIDPublicNetworkUpperLimit` in VSD API.
"""
self._vnid_public_network_upper_limit = value
@property
def vnid_upper_limit(self):
""" Get vnid_upper_limit value.
Notes:
Virtual network ID upper limit
This attribute is named `VNIDUpperLimit` in VSD API.
"""
return self._vnid_upper_limit
@vnid_upper_limit.setter
def vnid_upper_limit(self, value):
""" Set vnid_upper_limit value.
Notes:
Virtual network ID upper limit
This attribute is named `VNIDUpperLimit` in VSD API.
"""
self._vnid_upper_limit = value
@property
def api_key_renewal_interval(self):
""" Get api_key_renewal_interval value.
Notes:
Defines the interval in seconds, before the expiry time, that can used to renew the apiKey by making me API call. Minimum value is 1 min and maximum is 5 min.
This attribute is named `APIKeyRenewalInterval` in VSD API.
"""
return self._api_key_renewal_interval
@api_key_renewal_interval.setter
def api_key_renewal_interval(self, value):
""" Set api_key_renewal_interval value.
Notes:
Defines the interval in seconds, before the expiry time, that can used to renew the apiKey by making me API call. Minimum value is 1 min and maximum is 5 min.
This attribute is named `APIKeyRenewalInterval` in VSD API.
"""
self._api_key_renewal_interval = value
@property
def api_key_validity(self):
""" Get api_key_validity value.
Notes:
Defines the apiKey validity duration in seconds. Default is 24 hours and minimum value is 10 min.
This attribute is named `APIKeyValidity` in VSD API.
"""
return self._api_key_validity
@api_key_validity.setter
def api_key_validity(self, value):
""" Set api_key_validity value.
Notes:
Defines the apiKey validity duration in seconds. Default is 24 hours and minimum value is 10 min.
This attribute is named `APIKeyValidity` in VSD API.
"""
self._api_key_validity = value
@property
def lru_cache_size_per_subnet(self):
""" Get lru_cache_size_per_subnet value.
Notes:
LRU Map size per subnet (to hold the deleted vm's ip addresses).
This attribute is named `LRUCacheSizePerSubnet` in VSD API.
"""
return self._lru_cache_size_per_subnet
@lru_cache_size_per_subnet.setter
def lru_cache_size_per_subnet(self, value):
""" Set lru_cache_size_per_subnet value.
Notes:
LRU Map size per subnet (to hold the deleted vm's ip addresses).
This attribute is named `LRUCacheSizePerSubnet` in VSD API.
"""
self._lru_cache_size_per_subnet = value
@property
def vsc_on_same_version_as_vsd(self):
""" Get vsc_on_same_version_as_vsd value.
Notes:
This flag is used to indicate that whether VSC is on the same version as VSD or not.
This attribute is named `VSCOnSameVersionAsVSD` in VSD API.
"""
return self._vsc_on_same_version_as_vsd
@vsc_on_same_version_as_vsd.setter
def vsc_on_same_version_as_vsd(self, value):
""" Set vsc_on_same_version_as_vsd value.
Notes:
This flag is used to indicate that whether VSC is on the same version as VSD or not.
This attribute is named `VSCOnSameVersionAsVSD` in VSD API.
"""
self._vsc_on_same_version_as_vsd = value
@property
def vsd_read_only_mode(self):
""" Get vsd_read_only_mode value.
Notes:
True means VSD readonly mode enabled. False means VSD readonly mode disabled
This attribute is named `VSDReadOnlyMode` in VSD API.
"""
return self._vsd_read_only_mode
@vsd_read_only_mode.setter
def vsd_read_only_mode(self, value):
""" Set vsd_read_only_mode value.
Notes:
True means VSD readonly mode enabled. False means VSD readonly mode disabled
This attribute is named `VSDReadOnlyMode` in VSD API.
"""
self._vsd_read_only_mode = value
@property
def vsd_upgrade_is_complete(self):
""" Get vsd_upgrade_is_complete value.
Notes:
This flag is used to indicate that whether VSD upgrade is complete,it is expected that csproot will set to true,after VSD upgrade is complete and also making sure that all VSC's audits and Gateway audits with VSD are done
This attribute is named `VSDUpgradeIsComplete` in VSD API.
"""
return self._vsd_upgrade_is_complete
@vsd_upgrade_is_complete.setter
def vsd_upgrade_is_complete(self, value):
""" Set vsd_upgrade_is_complete value.
Notes:
This flag is used to indicate that whether VSD upgrade is complete,it is expected that csproot will set to true,after VSD upgrade is complete and also making sure that all VSC's audits and Gateway audits with VSD are done
This attribute is named `VSDUpgradeIsComplete` in VSD API.
"""
self._vsd_upgrade_is_complete = value
@property
def as_number(self):
""" Get as_number value.
Notes:
Autonomous System Number,Used for RT/RD auto-generation
This attribute is named `ASNumber` in VSD API.
"""
return self._as_number
@as_number.setter
def as_number(self, value):
""" Set as_number value.
Notes:
Autonomous System Number,Used for RT/RD auto-generation
This attribute is named `ASNumber` in VSD API.
"""
self._as_number = value
@property
def rt_lower_limit(self):
""" Get rt_lower_limit value.
Notes:
route target lower limit
This attribute is named `RTLowerLimit` in VSD API.
"""
return self._rt_lower_limit
@rt_lower_limit.setter
def rt_lower_limit(self, value):
""" Set rt_lower_limit value.
Notes:
route target lower limit
This attribute is named `RTLowerLimit` in VSD API.
"""
self._rt_lower_limit = value
@property
def rt_public_network_lower_limit(self):
""" Get rt_public_network_lower_limit value.
Notes:
route target public network lower limit
This attribute is named `RTPublicNetworkLowerLimit` in VSD API.
"""
return self._rt_public_network_lower_limit
@rt_public_network_lower_limit.setter
def rt_public_network_lower_limit(self, value):
""" Set rt_public_network_lower_limit value.
Notes:
route target public network lower limit
This attribute is named `RTPublicNetworkLowerLimit` in VSD API.
"""
self._rt_public_network_lower_limit = value
@property
def rt_public_network_upper_limit(self):
""" Get rt_public_network_upper_limit value.
Notes:
route target public network upper limit
This attribute is named `RTPublicNetworkUpperLimit` in VSD API.
"""
return self._rt_public_network_upper_limit
@rt_public_network_upper_limit.setter
def rt_public_network_upper_limit(self, value):
""" Set rt_public_network_upper_limit value.
Notes:
route target public network upper limit
This attribute is named `RTPublicNetworkUpperLimit` in VSD API.
"""
self._rt_public_network_upper_limit = value
@property
def rt_upper_limit(self):
""" Get rt_upper_limit value.
Notes:
route target upper limit
This attribute is named `RTUpperLimit` in VSD API.
"""
return self._rt_upper_limit
@rt_upper_limit.setter
def rt_upper_limit(self, value):
""" Set rt_upper_limit value.
Notes:
route target upper limit
This attribute is named `RTUpperLimit` in VSD API.
"""
self._rt_upper_limit = value
@property
def evpnbgp_community_tag_as_number(self):
""" Get evpnbgp_community_tag_as_number value.
Notes:
Autonomous System Number,Used for EVPNBGPCommunityTag auto-generation
This attribute is named `EVPNBGPCommunityTagASNumber` in VSD API.
"""
return self._evpnbgp_community_tag_as_number
@evpnbgp_community_tag_as_number.setter
def evpnbgp_community_tag_as_number(self, value):
""" Set evpnbgp_community_tag_as_number value.
Notes:
Autonomous System Number,Used for EVPNBGPCommunityTag auto-generation
This attribute is named `EVPNBGPCommunityTagASNumber` in VSD API.
"""
self._evpnbgp_community_tag_as_number = value
@property
def evpnbgp_community_tag_lower_limit(self):
""" Get evpnbgp_community_tag_lower_limit value.
Notes:
EVPNBGPCommunityTag lower limit
This attribute is named `EVPNBGPCommunityTagLowerLimit` in VSD API.
"""
return self._evpnbgp_community_tag_lower_limit
@evpnbgp_community_tag_lower_limit.setter
def evpnbgp_community_tag_lower_limit(self, value):
""" Set evpnbgp_community_tag_lower_limit value.
Notes:
EVPNBGPCommunityTag lower limit
This attribute is named `EVPNBGPCommunityTagLowerLimit` in VSD API.
"""
self._evpnbgp_community_tag_lower_limit = value
@property
def evpnbgp_community_tag_upper_limit(self):
""" Get evpnbgp_community_tag_upper_limit value.
Notes:
EVPNBGPCommunityTag upper limit
This attribute is named `EVPNBGPCommunityTagUpperLimit` in VSD API.
"""
return self._evpnbgp_community_tag_upper_limit
@evpnbgp_community_tag_upper_limit.setter
def evpnbgp_community_tag_upper_limit(self, value):
""" Set evpnbgp_community_tag_upper_limit value.
Notes:
EVPNBGPCommunityTag upper limit
This attribute is named `EVPNBGPCommunityTagUpperLimit` in VSD API.
"""
self._evpnbgp_community_tag_upper_limit = value
@property
def page_max_size(self):
""" Get page_max_size value.
Notes:
Defines upper bound for the page size. Configured or input page size should be less than this max page size.
This attribute is named `pageMaxSize` in VSD API.
"""
return self._page_max_size
@page_max_size.setter
def page_max_size(self, value):
""" Set page_max_size value.
Notes:
Defines upper bound for the page size. Configured or input page size should be less than this max page size.
This attribute is named `pageMaxSize` in VSD API.
"""
self._page_max_size = value
@property
def page_size(self):
""" Get page_size value.
Notes:
Defines the page size for the results returned by the REST call.
This attribute is named `pageSize` in VSD API.
"""
return self._page_size
@page_size.setter
def page_size(self, value):
""" Set page_size value.
Notes:
Defines the page size for the results returned by the REST call.
This attribute is named `pageSize` in VSD API.
"""
self._page_size = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def max_failed_logins(self):
""" Get max_failed_logins value.
Notes:
Maximum failed login attempts before the account is locked (min = 5, max = 10). 0 = not enforced (unlimited attempts). This is not enforced if LDAP is used for authorization
This attribute is named `maxFailedLogins` in VSD API.
"""
return self._max_failed_logins
@max_failed_logins.setter
def max_failed_logins(self, value):
""" Set max_failed_logins value.
Notes:
Maximum failed login attempts before the account is locked (min = 5, max = 10). 0 = not enforced (unlimited attempts). This is not enforced if LDAP is used for authorization
This attribute is named `maxFailedLogins` in VSD API.
"""
self._max_failed_logins = value
@property
def max_response(self):
""" Get max_response value.
Notes:
Defines maximum results returned by the REST call (allowed max=5000).
This attribute is named `maxResponse` in VSD API.
"""
return self._max_response
@max_response.setter
def max_response(self, value):
""" Set max_response value.
Notes:
Defines maximum results returned by the REST call (allowed max=5000).
This attribute is named `maxResponse` in VSD API.
"""
self._max_response = value
@property
def reflexive_acl_timeout(self):
""" Get reflexive_acl_timeout value.
Notes:
Defines the timeout in seconds for reflexive ACLs. This value applies for both TCP and UDP connections. Default value is 180 seconds and the timeout should be between 10 to 86400 seconds.
This attribute is named `reflexiveACLTimeout` in VSD API.
"""
return self._reflexive_acl_timeout
@reflexive_acl_timeout.setter
def reflexive_acl_timeout(self, value):
""" Set reflexive_acl_timeout value.
Notes:
Defines the timeout in seconds for reflexive ACLs. This value applies for both TCP and UDP connections. Default value is 180 seconds and the timeout should be between 10 to 86400 seconds.
This attribute is named `reflexiveACLTimeout` in VSD API.
"""
self._reflexive_acl_timeout = value
@property
def service_id_upper_limit(self):
""" Get service_id_upper_limit value.
Notes:
Service id upper limit system wide value
This attribute is named `serviceIDUpperLimit` in VSD API.
"""
return self._service_id_upper_limit
@service_id_upper_limit.setter
def service_id_upper_limit(self, value):
""" Set service_id_upper_limit value.
Notes:
Service id upper limit system wide value
This attribute is named `serviceIDUpperLimit` in VSD API.
"""
self._service_id_upper_limit = value
@property
def key_server_monitor_enabled(self):
""" Get key_server_monitor_enabled value.
Notes:
Enable the keyserver debug monitor (ie. ksmon command)
This attribute is named `keyServerMonitorEnabled` in VSD API.
"""
return self._key_server_monitor_enabled
@key_server_monitor_enabled.setter
def key_server_monitor_enabled(self, value):
""" Set key_server_monitor_enabled value.
Notes:
Enable the keyserver debug monitor (ie. ksmon command)
This attribute is named `keyServerMonitorEnabled` in VSD API.
"""
self._key_server_monitor_enabled = value
@property
def key_server_vsd_data_synchronization_interval(self):
""" Get key_server_vsd_data_synchronization_interval value.
Notes:
KeyServer time in seconds between full resyncs of VSD data (just in case of missed events)
This attribute is named `keyServerVSDDataSynchronizationInterval` in VSD API.
"""
return self._key_server_vsd_data_synchronization_interval
@key_server_vsd_data_synchronization_interval.setter
def key_server_vsd_data_synchronization_interval(self, value):
""" Set key_server_vsd_data_synchronization_interval value.
Notes:
KeyServer time in seconds between full resyncs of VSD data (just in case of missed events)
This attribute is named `keyServerVSDDataSynchronizationInterval` in VSD API.
"""
self._key_server_vsd_data_synchronization_interval = value
@property
def offset_customer_id(self):
""" Get offset_customer_id value.
Notes:
Customer id offset, this value has to be set before jboss starts , after that any change of value is ignored (minexclusive = 0, max = 20000) system wide value
This attribute is named `offsetCustomerID` in VSD API.
"""
return self._offset_customer_id
@offset_customer_id.setter
def offset_customer_id(self, value):
""" Set offset_customer_id value.
Notes:
Customer id offset, this value has to be set before jboss starts , after that any change of value is ignored (minexclusive = 0, max = 20000) system wide value
This attribute is named `offsetCustomerID` in VSD API.
"""
self._offset_customer_id = value
@property
def offset_service_id(self):
""" Get offset_service_id value.
Notes:
Service id offset, this value has to be set before jboss starts during install time, after that any change of value is ignored (minexclusive = 0, max = 40000) system wide value
This attribute is named `offsetServiceID` in VSD API.
"""
return self._offset_service_id
@offset_service_id.setter
def offset_service_id(self, value):
""" Set offset_service_id value.
Notes:
Service id offset, this value has to be set before jboss starts during install time, after that any change of value is ignored (minexclusive = 0, max = 40000) system wide value
This attribute is named `offsetServiceID` in VSD API.
"""
self._offset_service_id = value
@property
def ejbca_nsg_certificate_profile(self):
""" Get ejbca_nsg_certificate_profile value.
Notes:
EJBCA NSG Certificate Profile
This attribute is named `ejbcaNSGCertificateProfile` in VSD API.
"""
return self._ejbca_nsg_certificate_profile
@ejbca_nsg_certificate_profile.setter
def ejbca_nsg_certificate_profile(self, value):
""" Set ejbca_nsg_certificate_profile value.
Notes:
EJBCA NSG Certificate Profile
This attribute is named `ejbcaNSGCertificateProfile` in VSD API.
"""
self._ejbca_nsg_certificate_profile = value
@property
def ejbca_nsg_end_entity_profile(self):
""" Get ejbca_nsg_end_entity_profile value.
Notes:
EJBCA NSG End Entity Profile
This attribute is named `ejbcaNSGEndEntityProfile` in VSD API.
"""
return self._ejbca_nsg_end_entity_profile
@ejbca_nsg_end_entity_profile.setter
def ejbca_nsg_end_entity_profile(self, value):
""" Set ejbca_nsg_end_entity_profile value.
Notes:
EJBCA NSG End Entity Profile
This attribute is named `ejbcaNSGEndEntityProfile` in VSD API.
"""
self._ejbca_nsg_end_entity_profile = value
@property
def ejbca_ocsp_responder_cn(self):
""" Get ejbca_ocsp_responder_cn value.
Notes:
EJBCA OCSP Responder CommonName
This attribute is named `ejbcaOCSPResponderCN` in VSD API.
"""
return self._ejbca_ocsp_responder_cn
@ejbca_ocsp_responder_cn.setter
def ejbca_ocsp_responder_cn(self, value):
""" Set ejbca_ocsp_responder_cn value.
Notes:
EJBCA OCSP Responder CommonName
This attribute is named `ejbcaOCSPResponderCN` in VSD API.
"""
self._ejbca_ocsp_responder_cn = value
@property
def ejbca_ocsp_responder_uri(self):
""" Get ejbca_ocsp_responder_uri value.
Notes:
EJBCA OCSP Responder URI
This attribute is named `ejbcaOCSPResponderURI` in VSD API.
"""
return self._ejbca_ocsp_responder_uri
@ejbca_ocsp_responder_uri.setter
def ejbca_ocsp_responder_uri(self, value):
""" Set ejbca_ocsp_responder_uri value.
Notes:
EJBCA OCSP Responder URI
This attribute is named `ejbcaOCSPResponderURI` in VSD API.
"""
self._ejbca_ocsp_responder_uri = value
@property
def ejbca_vsp_root_ca(self):
""" Get ejbca_vsp_root_ca value.
Notes:
EJBCA VSP CA
This attribute is named `ejbcaVspRootCa` in VSD API.
"""
return self._ejbca_vsp_root_ca
@ejbca_vsp_root_ca.setter
def ejbca_vsp_root_ca(self, value):
""" Set ejbca_vsp_root_ca value.
Notes:
EJBCA VSP CA
This attribute is named `ejbcaVspRootCa` in VSD API.
"""
self._ejbca_vsp_root_ca = value
@property
def alarms_max_per_object(self):
""" Get alarms_max_per_object value.
Notes:
Maximum alarms per object for example max distinct alarms for specific VM (min = 5, max =20)
This attribute is named `alarmsMaxPerObject` in VSD API.
"""
return self._alarms_max_per_object
@alarms_max_per_object.setter
def alarms_max_per_object(self, value):
""" Set alarms_max_per_object value.
Notes:
Maximum alarms per object for example max distinct alarms for specific VM (min = 5, max =20)
This attribute is named `alarmsMaxPerObject` in VSD API.
"""
self._alarms_max_per_object = value
@property
def elastic_cluster_name(self):
""" Get elastic_cluster_name value.
Notes:
Specifies the name of the Elastic Search Cluster.
This attribute is named `elasticClusterName` in VSD API.
"""
return self._elastic_cluster_name
@elastic_cluster_name.setter
def elastic_cluster_name(self, value):
""" Set elastic_cluster_name value.
Notes:
Specifies the name of the Elastic Search Cluster.
This attribute is named `elasticClusterName` in VSD API.
"""
self._elastic_cluster_name = value
@property
def inactive_timeout(self):
""" Get inactive_timeout value.
Notes:
Defines the inactive timeout for the client. If the client is inactive for more than timeout, server clears off all the cache/information regarding the client. This value should be greater than event processor max timeout
This attribute is named `inactiveTimeout` in VSD API.
"""
return self._inactive_timeout
@inactive_timeout.setter
def inactive_timeout(self, value):
""" Set inactive_timeout value.
Notes:
Defines the inactive timeout for the client. If the client is inactive for more than timeout, server clears off all the cache/information regarding the client. This value should be greater than event processor max timeout
This attribute is named `inactiveTimeout` in VSD API.
"""
self._inactive_timeout = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def domain_tunnel_type(self):
""" Get domain_tunnel_type value.
Notes:
Default Domain Tunnel Type .Possible values are VXLAN,GRE Possible values are DC_DEFAULT, GRE, VXLAN, .
This attribute is named `domainTunnelType` in VSD API.
"""
return self._domain_tunnel_type
@domain_tunnel_type.setter
def domain_tunnel_type(self, value):
""" Set domain_tunnel_type value.
Notes:
Default Domain Tunnel Type .Possible values are VXLAN,GRE Possible values are DC_DEFAULT, GRE, VXLAN, .
This attribute is named `domainTunnelType` in VSD API.
"""
self._domain_tunnel_type = value
@property
def post_processor_threads_count(self):
""" Get post_processor_threads_count value.
Notes:
Post processor thread count.
This attribute is named `postProcessorThreadsCount` in VSD API.
"""
return self._post_processor_threads_count
@post_processor_threads_count.setter
def post_processor_threads_count(self, value):
""" Set post_processor_threads_count value.
Notes:
Post processor thread count.
This attribute is named `postProcessorThreadsCount` in VSD API.
"""
self._post_processor_threads_count = value
@property
def group_key_default_sek_generation_interval(self):
""" Get group_key_default_sek_generation_interval value.
Notes:
Group Key Encryption Profile Default SEK Generation Interval
This attribute is named `groupKeyDefaultSEKGenerationInterval` in VSD API.
"""
return self._group_key_default_sek_generation_interval
@group_key_default_sek_generation_interval.setter
def group_key_default_sek_generation_interval(self, value):
""" Set group_key_default_sek_generation_interval value.
Notes:
Group Key Encryption Profile Default SEK Generation Interval
This attribute is named `groupKeyDefaultSEKGenerationInterval` in VSD API.
"""
self._group_key_default_sek_generation_interval = value
@property
def group_key_default_sek_lifetime(self):
""" Get group_key_default_sek_lifetime value.
Notes:
Group Key Encryption Profile Default SEK Lifetime
This attribute is named `groupKeyDefaultSEKLifetime` in VSD API.
"""
return self._group_key_default_sek_lifetime
@group_key_default_sek_lifetime.setter
def group_key_default_sek_lifetime(self, value):
""" Set group_key_default_sek_lifetime value.
Notes:
Group Key Encryption Profile Default SEK Lifetime
This attribute is named `groupKeyDefaultSEKLifetime` in VSD API.
"""
self._group_key_default_sek_lifetime = value
@property
def group_key_default_sek_payload_encryption_algorithm(self):
""" Get group_key_default_sek_payload_encryption_algorithm value.
Notes:
Group Key Encryption Profile Default Sek Payload Encryption Algorithm.
This attribute is named `groupKeyDefaultSEKPayloadEncryptionAlgorithm` in VSD API.
"""
return self._group_key_default_sek_payload_encryption_algorithm
@group_key_default_sek_payload_encryption_algorithm.setter
def group_key_default_sek_payload_encryption_algorithm(self, value):
""" Set group_key_default_sek_payload_encryption_algorithm value.
Notes:
Group Key Encryption Profile Default Sek Payload Encryption Algorithm.
This attribute is named `groupKeyDefaultSEKPayloadEncryptionAlgorithm` in VSD API.
"""
self._group_key_default_sek_payload_encryption_algorithm = value
@property
def group_key_default_sek_payload_signing_algorithm(self):
""" Get group_key_default_sek_payload_signing_algorithm value.
Notes:
Group Key Encryption Profile Default Sek Payload Signing Algorithm.
This attribute is named `groupKeyDefaultSEKPayloadSigningAlgorithm` in VSD API.
"""
return self._group_key_default_sek_payload_signing_algorithm
@group_key_default_sek_payload_signing_algorithm.setter
def group_key_default_sek_payload_signing_algorithm(self, value):
""" Set group_key_default_sek_payload_signing_algorithm value.
Notes:
Group Key Encryption Profile Default Sek Payload Signing Algorithm.
This attribute is named `groupKeyDefaultSEKPayloadSigningAlgorithm` in VSD API.
"""
self._group_key_default_sek_payload_signing_algorithm = value
@property
def group_key_default_seed_generation_interval(self):
""" Get group_key_default_seed_generation_interval value.
Notes:
Group Key Encryption Profile Default Seed Generation Interval
This attribute is named `groupKeyDefaultSeedGenerationInterval` in VSD API.
"""
return self._group_key_default_seed_generation_interval
@group_key_default_seed_generation_interval.setter
def group_key_default_seed_generation_interval(self, value):
""" Set group_key_default_seed_generation_interval value.
Notes:
Group Key Encryption Profile Default Seed Generation Interval
This attribute is named `groupKeyDefaultSeedGenerationInterval` in VSD API.
"""
self._group_key_default_seed_generation_interval = value
@property
def group_key_default_seed_lifetime(self):
""" Get group_key_default_seed_lifetime value.
Notes:
Group Key Encryption Profile Default Seed Lifetime
This attribute is named `groupKeyDefaultSeedLifetime` in VSD API.
"""
return self._group_key_default_seed_lifetime
@group_key_default_seed_lifetime.setter
def group_key_default_seed_lifetime(self, value):
""" Set group_key_default_seed_lifetime value.
Notes:
Group Key Encryption Profile Default Seed Lifetime
This attribute is named `groupKeyDefaultSeedLifetime` in VSD API.
"""
self._group_key_default_seed_lifetime = value
@property
def group_key_default_seed_payload_authentication_algorithm(self):
""" Get group_key_default_seed_payload_authentication_algorithm value.
Notes:
Group Key Encryption Profile Default Seed Payload Authentication Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadAuthenticationAlgorithm` in VSD API.
"""
return self._group_key_default_seed_payload_authentication_algorithm
@group_key_default_seed_payload_authentication_algorithm.setter
def group_key_default_seed_payload_authentication_algorithm(self, value):
""" Set group_key_default_seed_payload_authentication_algorithm value.
Notes:
Group Key Encryption Profile Default Seed Payload Authentication Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadAuthenticationAlgorithm` in VSD API.
"""
self._group_key_default_seed_payload_authentication_algorithm = value
@property
def group_key_default_seed_payload_encryption_algorithm(self):
""" Get group_key_default_seed_payload_encryption_algorithm value.
Notes:
Group Key Encryption Profile Default Seed Payload Encryption Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadEncryptionAlgorithm` in VSD API.
"""
return self._group_key_default_seed_payload_encryption_algorithm
@group_key_default_seed_payload_encryption_algorithm.setter
def group_key_default_seed_payload_encryption_algorithm(self, value):
""" Set group_key_default_seed_payload_encryption_algorithm value.
Notes:
Group Key Encryption Profile Default Seed Payload Encryption Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadEncryptionAlgorithm` in VSD API.
"""
self._group_key_default_seed_payload_encryption_algorithm = value
@property
def group_key_default_seed_payload_signing_algorithm(self):
""" Get group_key_default_seed_payload_signing_algorithm value.
Notes:
Group Key Encryption Profile Default Seed Payload Signature Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadSigningAlgorithm` in VSD API.
"""
return self._group_key_default_seed_payload_signing_algorithm
@group_key_default_seed_payload_signing_algorithm.setter
def group_key_default_seed_payload_signing_algorithm(self, value):
""" Set group_key_default_seed_payload_signing_algorithm value.
Notes:
Group Key Encryption Profile Default Seed Payload Signature Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadSigningAlgorithm` in VSD API.
"""
self._group_key_default_seed_payload_signing_algorithm = value
@property
def group_key_default_traffic_authentication_algorithm(self):
""" Get group_key_default_traffic_authentication_algorithm value.
Notes:
Group Key Encryption Profile Default Traffic Authentication Algorithm.
This attribute is named `groupKeyDefaultTrafficAuthenticationAlgorithm` in VSD API.
"""
return self._group_key_default_traffic_authentication_algorithm
@group_key_default_traffic_authentication_algorithm.setter
def group_key_default_traffic_authentication_algorithm(self, value):
""" Set group_key_default_traffic_authentication_algorithm value.
Notes:
Group Key Encryption Profile Default Traffic Authentication Algorithm.
This attribute is named `groupKeyDefaultTrafficAuthenticationAlgorithm` in VSD API.
"""
self._group_key_default_traffic_authentication_algorithm = value
@property
def group_key_default_traffic_encryption_algorithm(self):
""" Get group_key_default_traffic_encryption_algorithm value.
Notes:
Group Key Encryption Profile Default Traffic Encryption Algorithm.
This attribute is named `groupKeyDefaultTrafficEncryptionAlgorithm` in VSD API.
"""
return self._group_key_default_traffic_encryption_algorithm
@group_key_default_traffic_encryption_algorithm.setter
def group_key_default_traffic_encryption_algorithm(self, value):
""" Set group_key_default_traffic_encryption_algorithm value.
Notes:
Group Key Encryption Profile Default Traffic Encryption Algorithm.
This attribute is named `groupKeyDefaultTrafficEncryptionAlgorithm` in VSD API.
"""
self._group_key_default_traffic_encryption_algorithm = value
@property
def group_key_default_traffic_encryption_key_lifetime(self):
""" Get group_key_default_traffic_encryption_key_lifetime value.
Notes:
Group Key Encryption Profile Default Traffic Encryption Key Lifetime
This attribute is named `groupKeyDefaultTrafficEncryptionKeyLifetime` in VSD API.
"""
return self._group_key_default_traffic_encryption_key_lifetime
@group_key_default_traffic_encryption_key_lifetime.setter
def group_key_default_traffic_encryption_key_lifetime(self, value):
""" Set group_key_default_traffic_encryption_key_lifetime value.
Notes:
Group Key Encryption Profile Default Traffic Encryption Key Lifetime
This attribute is named `groupKeyDefaultTrafficEncryptionKeyLifetime` in VSD API.
"""
self._group_key_default_traffic_encryption_key_lifetime = value
@property
def group_key_generation_interval_on_forced_re_key(self):
""" Get group_key_generation_interval_on_forced_re_key value.
Notes:
Time in seconds before new keys will be generated in the case of a forced re-key event
This attribute is named `groupKeyGenerationIntervalOnForcedReKey` in VSD API.
"""
return self._group_key_generation_interval_on_forced_re_key
@group_key_generation_interval_on_forced_re_key.setter
def group_key_generation_interval_on_forced_re_key(self, value):
""" Set group_key_generation_interval_on_forced_re_key value.
Notes:
Time in seconds before new keys will be generated in the case of a forced re-key event
This attribute is named `groupKeyGenerationIntervalOnForcedReKey` in VSD API.
"""
self._group_key_generation_interval_on_forced_re_key = value
@property
def group_key_generation_interval_on_revoke(self):
""" Get group_key_generation_interval_on_revoke value.
Notes:
Time in seconds before new keys will be generated in the case of a revoke event
This attribute is named `groupKeyGenerationIntervalOnRevoke` in VSD API.
"""
return self._group_key_generation_interval_on_revoke
@group_key_generation_interval_on_revoke.setter
def group_key_generation_interval_on_revoke(self, value):
""" Set group_key_generation_interval_on_revoke value.
Notes:
Time in seconds before new keys will be generated in the case of a revoke event
This attribute is named `groupKeyGenerationIntervalOnRevoke` in VSD API.
"""
self._group_key_generation_interval_on_revoke = value
@property
def group_key_minimum_sek_generation_interval(self):
""" Get group_key_minimum_sek_generation_interval value.
Notes:
Group Key Encryption Profile Minimum SEK Generation Interval
This attribute is named `groupKeyMinimumSEKGenerationInterval` in VSD API.
"""
return self._group_key_minimum_sek_generation_interval
@group_key_minimum_sek_generation_interval.setter
def group_key_minimum_sek_generation_interval(self, value):
""" Set group_key_minimum_sek_generation_interval value.
Notes:
Group Key Encryption Profile Minimum SEK Generation Interval
This attribute is named `groupKeyMinimumSEKGenerationInterval` in VSD API.
"""
self._group_key_minimum_sek_generation_interval = value
@property
def group_key_minimum_sek_lifetime(self):
""" Get group_key_minimum_sek_lifetime value.
Notes:
Group Key Encryption Profile Minimum SEK Lifetime
This attribute is named `groupKeyMinimumSEKLifetime` in VSD API.
"""
return self._group_key_minimum_sek_lifetime
@group_key_minimum_sek_lifetime.setter
def group_key_minimum_sek_lifetime(self, value):
""" Set group_key_minimum_sek_lifetime value.
Notes:
Group Key Encryption Profile Minimum SEK Lifetime
This attribute is named `groupKeyMinimumSEKLifetime` in VSD API.
"""
self._group_key_minimum_sek_lifetime = value
@property
def group_key_minimum_seed_generation_interval(self):
""" Get group_key_minimum_seed_generation_interval value.
Notes:
Group Key Encryption Profile Default Seed Generation Interval
This attribute is named `groupKeyMinimumSeedGenerationInterval` in VSD API.
"""
return self._group_key_minimum_seed_generation_interval
@group_key_minimum_seed_generation_interval.setter
def group_key_minimum_seed_generation_interval(self, value):
""" Set group_key_minimum_seed_generation_interval value.
Notes:
Group Key Encryption Profile Default Seed Generation Interval
This attribute is named `groupKeyMinimumSeedGenerationInterval` in VSD API.
"""
self._group_key_minimum_seed_generation_interval = value
@property
def group_key_minimum_seed_lifetime(self):
""" Get group_key_minimum_seed_lifetime value.
Notes:
Group Key Encryption Profile Default Seed Lifetime
This attribute is named `groupKeyMinimumSeedLifetime` in VSD API.
"""
return self._group_key_minimum_seed_lifetime
@group_key_minimum_seed_lifetime.setter
def group_key_minimum_seed_lifetime(self, value):
""" Set group_key_minimum_seed_lifetime value.
Notes:
Group Key Encryption Profile Default Seed Lifetime
This attribute is named `groupKeyMinimumSeedLifetime` in VSD API.
"""
self._group_key_minimum_seed_lifetime = value
@property
def group_key_minimum_traffic_encryption_key_lifetime(self):
""" Get group_key_minimum_traffic_encryption_key_lifetime value.
Notes:
Group Key Encryption Profile Minimum TEK Lifetime
This attribute is named `groupKeyMinimumTrafficEncryptionKeyLifetime` in VSD API.
"""
return self._group_key_minimum_traffic_encryption_key_lifetime
@group_key_minimum_traffic_encryption_key_lifetime.setter
def group_key_minimum_traffic_encryption_key_lifetime(self, value):
""" Set group_key_minimum_traffic_encryption_key_lifetime value.
Notes:
Group Key Encryption Profile Minimum TEK Lifetime
This attribute is named `groupKeyMinimumTrafficEncryptionKeyLifetime` in VSD API.
"""
self._group_key_minimum_traffic_encryption_key_lifetime = value
@property
def nsg_bootstrap_endpoint(self):
""" Get nsg_bootstrap_endpoint value.
Notes:
NSG Bootstrap Endpoint
This attribute is named `nsgBootstrapEndpoint` in VSD API.
"""
return self._nsg_bootstrap_endpoint
@nsg_bootstrap_endpoint.setter
def nsg_bootstrap_endpoint(self, value):
""" Set nsg_bootstrap_endpoint value.
Notes:
NSG Bootstrap Endpoint
This attribute is named `nsgBootstrapEndpoint` in VSD API.
"""
self._nsg_bootstrap_endpoint = value
@property
def nsg_config_endpoint(self):
""" Get nsg_config_endpoint value.
Notes:
NSG Config Endpoint
This attribute is named `nsgConfigEndpoint` in VSD API.
"""
return self._nsg_config_endpoint
@nsg_config_endpoint.setter
def nsg_config_endpoint(self, value):
""" Set nsg_config_endpoint value.
Notes:
NSG Config Endpoint
This attribute is named `nsgConfigEndpoint` in VSD API.
"""
self._nsg_config_endpoint = value
@property
def nsg_local_ui_url(self):
""" Get nsg_local_ui_url value.
Notes:
NSG Local UI URL - will be redirected on NSG to localhost
This attribute is named `nsgLocalUiUrl` in VSD API.
"""
return self._nsg_local_ui_url
@nsg_local_ui_url.setter
def nsg_local_ui_url(self, value):
""" Set nsg_local_ui_url value.
Notes:
NSG Local UI URL - will be redirected on NSG to localhost
This attribute is named `nsgLocalUiUrl` in VSD API.
"""
self._nsg_local_ui_url = value
@property
def esi_id(self):
""" Get esi_id value.
Notes:
ESI ID offset
This attribute is named `esiID` in VSD API.
"""
return self._esi_id
@esi_id.setter
def esi_id(self, value):
""" Set esi_id value.
Notes:
ESI ID offset
This attribute is named `esiID` in VSD API.
"""
self._esi_id = value
@property
def stack_trace_enabled(self):
""" Get stack_trace_enabled value.
Notes:
True to enable stacktrace in the REST call.
This attribute is named `stackTraceEnabled` in VSD API.
"""
return self._stack_trace_enabled
@stack_trace_enabled.setter
def stack_trace_enabled(self, value):
""" Set stack_trace_enabled value.
Notes:
True to enable stacktrace in the REST call.
This attribute is named `stackTraceEnabled` in VSD API.
"""
self._stack_trace_enabled = value
@property
def static_wan_service_purge_time(self):
""" Get static_wan_service_purge_time value.
Notes:
Timers in sec for unreacheable static WAN Services to be deleted.
This attribute is named `staticWANServicePurgeTime` in VSD API.
"""
return self._static_wan_service_purge_time
@static_wan_service_purge_time.setter
def static_wan_service_purge_time(self, value):
""" Set static_wan_service_purge_time value.
Notes:
Timers in sec for unreacheable static WAN Services to be deleted.
This attribute is named `staticWANServicePurgeTime` in VSD API.
"""
self._static_wan_service_purge_time = value
@property
def statistics_enabled(self):
""" Get statistics_enabled value.
Notes:
This flag is used to indicate if statistics is enabled in the system. CSProot is expected to activate this through the enable statistics script.
This attribute is named `statisticsEnabled` in VSD API.
"""
return self._statistics_enabled
@statistics_enabled.setter
def statistics_enabled(self, value):
""" Set statistics_enabled value.
Notes:
This flag is used to indicate if statistics is enabled in the system. CSProot is expected to activate this through the enable statistics script.
This attribute is named `statisticsEnabled` in VSD API.
"""
self._statistics_enabled = value
@property
def stats_collector_address(self):
""" Get stats_collector_address value.
Notes:
Specify the ip address(es) of the stats collector.
This attribute is named `statsCollectorAddress` in VSD API.
"""
return self._stats_collector_address
@stats_collector_address.setter
def stats_collector_address(self, value):
""" Set stats_collector_address value.
Notes:
Specify the ip address(es) of the stats collector.
This attribute is named `statsCollectorAddress` in VSD API.
"""
self._stats_collector_address = value
@property
def stats_collector_port(self):
""" Get stats_collector_port value.
Notes:
Specify the port number(s) of the stats collector.
This attribute is named `statsCollectorPort` in VSD API.
"""
return self._stats_collector_port
@stats_collector_port.setter
def stats_collector_port(self, value):
""" Set stats_collector_port value.
Notes:
Specify the port number(s) of the stats collector.
This attribute is named `statsCollectorPort` in VSD API.
"""
self._stats_collector_port = value
@property
def stats_collector_proto_buf_port(self):
""" Get stats_collector_proto_buf_port value.
Notes:
Specify the protobuf port number(s) of the stats collector.
This attribute is named `statsCollectorProtoBufPort` in VSD API.
"""
return self._stats_collector_proto_buf_port
@stats_collector_proto_buf_port.setter
def stats_collector_proto_buf_port(self, value):
""" Set stats_collector_proto_buf_port value.
Notes:
Specify the protobuf port number(s) of the stats collector.
This attribute is named `statsCollectorProtoBufPort` in VSD API.
"""
self._stats_collector_proto_buf_port = value
@property
def stats_max_data_points(self):
""" Get stats_max_data_points value.
Notes:
Specifies the maximum number of data points to support.
This attribute is named `statsMaxDataPoints` in VSD API.
"""
return self._stats_max_data_points
@stats_max_data_points.setter
def stats_max_data_points(self, value):
""" Set stats_max_data_points value.
Notes:
Specifies the maximum number of data points to support.
This attribute is named `statsMaxDataPoints` in VSD API.
"""
self._stats_max_data_points = value
@property
def stats_min_duration(self):
""" Get stats_min_duration value.
Notes:
Default minimum duration for statistics to be displayed in UI is 30 days in seconds.
This attribute is named `statsMinDuration` in VSD API.
"""
return self._stats_min_duration
@stats_min_duration.setter
def stats_min_duration(self, value):
""" Set stats_min_duration value.
Notes:
Default minimum duration for statistics to be displayed in UI is 30 days in seconds.
This attribute is named `statsMinDuration` in VSD API.
"""
self._stats_min_duration = value
@property
def stats_number_of_data_points(self):
""" Get stats_number_of_data_points value.
Notes:
Specifies number of data points.
This attribute is named `statsNumberOfDataPoints` in VSD API.
"""
return self._stats_number_of_data_points
@stats_number_of_data_points.setter
def stats_number_of_data_points(self, value):
""" Set stats_number_of_data_points value.
Notes:
Specifies number of data points.
This attribute is named `statsNumberOfDataPoints` in VSD API.
"""
self._stats_number_of_data_points = value
@property
def stats_tsdb_server_address(self):
""" Get stats_tsdb_server_address value.
Notes:
Specifies the TSDB server location.
This attribute is named `statsTSDBServerAddress` in VSD API.
"""
return self._stats_tsdb_server_address
@stats_tsdb_server_address.setter
def stats_tsdb_server_address(self, value):
""" Set stats_tsdb_server_address value.
Notes:
Specifies the TSDB server location.
This attribute is named `statsTSDBServerAddress` in VSD API.
"""
self._stats_tsdb_server_address = value
@property
def subnet_resync_interval(self):
""" Get subnet_resync_interval value.
Notes:
After resync on a subnet , another resync on the same subnet is allowed based on the below value subnet resync complete wait time in min.
This attribute is named `subnetResyncInterval` in VSD API.
"""
return self._subnet_resync_interval
@subnet_resync_interval.setter
def subnet_resync_interval(self, value):
""" Set subnet_resync_interval value.
Notes:
After resync on a subnet , another resync on the same subnet is allowed based on the below value subnet resync complete wait time in min.
This attribute is named `subnetResyncInterval` in VSD API.
"""
self._subnet_resync_interval = value
@property
def subnet_resync_outstanding_interval(self):
""" Get subnet_resync_outstanding_interval value.
Notes:
Outstanding subnet resync interval (in secs). System wide value.
This attribute is named `subnetResyncOutstandingInterval` in VSD API.
"""
return self._subnet_resync_outstanding_interval
@subnet_resync_outstanding_interval.setter
def subnet_resync_outstanding_interval(self, value):
""" Set subnet_resync_outstanding_interval value.
Notes:
Outstanding subnet resync interval (in secs). System wide value.
This attribute is named `subnetResyncOutstandingInterval` in VSD API.
"""
self._subnet_resync_outstanding_interval = value
@property
def customer_id_upper_limit(self):
""" Get customer_id_upper_limit value.
Notes:
Customer id upper limit, system wide value
This attribute is named `customerIDUpperLimit` in VSD API.
"""
return self._customer_id_upper_limit
@customer_id_upper_limit.setter
def customer_id_upper_limit(self, value):
""" Set customer_id_upper_limit value.
Notes:
Customer id upper limit, system wide value
This attribute is named `customerIDUpperLimit` in VSD API.
"""
self._customer_id_upper_limit = value
@property
def customer_key(self):
""" Get customer_key value.
Notes:
Customer key associated with the licese
This attribute is named `customerKey` in VSD API.
"""
return self._customer_key
@customer_key.setter
def customer_key(self, value):
""" Set customer_key value.
Notes:
Customer key associated with the licese
This attribute is named `customerKey` in VSD API.
"""
self._customer_key = value
@property
def avatar_base_path(self):
""" Get avatar_base_path value.
Notes:
Defines location where image files needs to be copied. Above URL should be configured to read the file from this location.
This attribute is named `avatarBasePath` in VSD API.
"""
return self._avatar_base_path
@avatar_base_path.setter
def avatar_base_path(self, value):
""" Set avatar_base_path value.
Notes:
Defines location where image files needs to be copied. Above URL should be configured to read the file from this location.
This attribute is named `avatarBasePath` in VSD API.
"""
self._avatar_base_path = value
@property
def avatar_base_url(self):
""" Get avatar_base_url value.
Notes:
Defines the url to read the avatar image files
This attribute is named `avatarBaseURL` in VSD API.
"""
return self._avatar_base_url
@avatar_base_url.setter
def avatar_base_url(self, value):
""" Set avatar_base_url value.
Notes:
Defines the url to read the avatar image files
This attribute is named `avatarBaseURL` in VSD API.
"""
self._avatar_base_url = value
@property
def event_log_cleanup_interval(self):
""" Get event_log_cleanup_interval value.
Notes:
Cleanup task run interval in seconds.
This attribute is named `eventLogCleanupInterval` in VSD API.
"""
return self._event_log_cleanup_interval
@event_log_cleanup_interval.setter
def event_log_cleanup_interval(self, value):
""" Set event_log_cleanup_interval value.
Notes:
Cleanup task run interval in seconds.
This attribute is named `eventLogCleanupInterval` in VSD API.
"""
self._event_log_cleanup_interval = value
@property
def event_log_entry_max_age(self):
""" Get event_log_entry_max_age value.
Notes:
Maximum age in days for cleanup of the eventlog entries. On every periodic interval run, any eventlog entries older than this max age will be deleted.
This attribute is named `eventLogEntryMaxAge` in VSD API.
"""
return self._event_log_entry_max_age
@event_log_entry_max_age.setter
def event_log_entry_max_age(self, value):
""" Set event_log_entry_max_age value.
Notes:
Maximum age in days for cleanup of the eventlog entries. On every periodic interval run, any eventlog entries older than this max age will be deleted.
This attribute is named `eventLogEntryMaxAge` in VSD API.
"""
self._event_log_entry_max_age = value
@property
def event_processor_interval(self):
""" Get event_processor_interval value.
Notes:
Defines time interval in milliseconds when events collected for a client should be processed.
This attribute is named `eventProcessorInterval` in VSD API.
"""
return self._event_processor_interval
@event_processor_interval.setter
def event_processor_interval(self, value):
""" Set event_processor_interval value.
Notes:
Defines time interval in milliseconds when events collected for a client should be processed.
This attribute is named `eventProcessorInterval` in VSD API.
"""
self._event_processor_interval = value
@property
def event_processor_max_events_count(self):
""" Get event_processor_max_events_count value.
Notes:
Defines the maximum number of events to be collected in case of events burst.
This attribute is named `eventProcessorMaxEventsCount` in VSD API.
"""
return self._event_processor_max_events_count
@event_processor_max_events_count.setter
def event_processor_max_events_count(self, value):
""" Set event_processor_max_events_count value.
Notes:
Defines the maximum number of events to be collected in case of events burst.
This attribute is named `eventProcessorMaxEventsCount` in VSD API.
"""
self._event_processor_max_events_count = value
@property
def event_processor_timeout(self):
""" Get event_processor_timeout value.
Notes:
Defines the maximum time period in milliseconds for the Rest server to wait before sending the events from the system.
This attribute is named `eventProcessorTimeout` in VSD API.
"""
return self._event_processor_timeout
@event_processor_timeout.setter
def event_processor_timeout(self, value):
""" Set event_processor_timeout value.
Notes:
Defines the maximum time period in milliseconds for the Rest server to wait before sending the events from the system.
This attribute is named `eventProcessorTimeout` in VSD API.
"""
self._event_processor_timeout = value
@property
def two_factor_code_expiry(self):
""" Get two_factor_code_expiry value.
Notes:
Two Factor Code Expiry in Seconds
This attribute is named `twoFactorCodeExpiry` in VSD API.
"""
return self._two_factor_code_expiry
@two_factor_code_expiry.setter
def two_factor_code_expiry(self, value):
""" Set two_factor_code_expiry value.
Notes:
Two Factor Code Expiry in Seconds
This attribute is named `twoFactorCodeExpiry` in VSD API.
"""
self._two_factor_code_expiry = value
@property
def two_factor_code_length(self):
""" Get two_factor_code_length value.
Notes:
Two Factor Code Length
This attribute is named `twoFactorCodeLength` in VSD API.
"""
return self._two_factor_code_length
@two_factor_code_length.setter
def two_factor_code_length(self, value):
""" Set two_factor_code_length value.
Notes:
Two Factor Code Length
This attribute is named `twoFactorCodeLength` in VSD API.
"""
self._two_factor_code_length = value
@property
def two_factor_code_seed_length(self):
""" Get two_factor_code_seed_length value.
Notes:
Two Factor Seed length in bytes
This attribute is named `twoFactorCodeSeedLength` in VSD API.
"""
return self._two_factor_code_seed_length
@two_factor_code_seed_length.setter
def two_factor_code_seed_length(self, value):
""" Set two_factor_code_seed_length value.
Notes:
Two Factor Seed length in bytes
This attribute is named `twoFactorCodeSeedLength` in VSD API.
"""
self._two_factor_code_seed_length = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def dynamic_wan_service_diff_time(self):
""" Get dynamic_wan_service_diff_time value.
Notes:
Timers in sec for dynamic WAN Services to be considered not seen by 7X50.
This attribute is named `dynamicWANServiceDiffTime` in VSD API.
"""
return self._dynamic_wan_service_diff_time
@dynamic_wan_service_diff_time.setter
def dynamic_wan_service_diff_time(self, value):
""" Set dynamic_wan_service_diff_time value.
Notes:
Timers in sec for dynamic WAN Services to be considered not seen by 7X50.
This attribute is named `dynamicWANServiceDiffTime` in VSD API.
"""
self._dynamic_wan_service_diff_time = value
@property
def syslog_destination_host(self):
""" Get syslog_destination_host value.
Notes:
Specifies the remote syslog destination host
This attribute is named `syslogDestinationHost` in VSD API.
"""
return self._syslog_destination_host
@syslog_destination_host.setter
def syslog_destination_host(self, value):
""" Set syslog_destination_host value.
Notes:
Specifies the remote syslog destination host
This attribute is named `syslogDestinationHost` in VSD API.
"""
self._syslog_destination_host = value
@property
def syslog_destination_port(self):
""" Get syslog_destination_port value.
Notes:
Specified the remote syslog destination port
This attribute is named `syslogDestinationPort` in VSD API.
"""
return self._syslog_destination_port
@syslog_destination_port.setter
def syslog_destination_port(self, value):
""" Set syslog_destination_port value.
Notes:
Specified the remote syslog destination port
This attribute is named `syslogDestinationPort` in VSD API.
"""
self._syslog_destination_port = value
@property
def sysmon_cleanup_task_interval(self):
""" Get sysmon_cleanup_task_interval value.
Notes:
Sysmon cleanup task run interval in seconds.
This attribute is named `sysmonCleanupTaskInterval` in VSD API.
"""
return self._sysmon_cleanup_task_interval
@sysmon_cleanup_task_interval.setter
def sysmon_cleanup_task_interval(self, value):
""" Set sysmon_cleanup_task_interval value.
Notes:
Sysmon cleanup task run interval in seconds.
This attribute is named `sysmonCleanupTaskInterval` in VSD API.
"""
self._sysmon_cleanup_task_interval = value
@property
def sysmon_node_presence_timeout(self):
""" Get sysmon_node_presence_timeout value.
Notes:
Node presence timeout in seconds if no messages.
This attribute is named `sysmonNodePresenceTimeout` in VSD API.
"""
return self._sysmon_node_presence_timeout
@sysmon_node_presence_timeout.setter
def sysmon_node_presence_timeout(self, value):
""" Set sysmon_node_presence_timeout value.
Notes:
Node presence timeout in seconds if no messages.
This attribute is named `sysmonNodePresenceTimeout` in VSD API.
"""
self._sysmon_node_presence_timeout = value
@property
def sysmon_probe_response_timeout(self):
""" Get sysmon_probe_response_timeout value.
Notes:
Probe response timeout in seconds.
This attribute is named `sysmonProbeResponseTimeout` in VSD API.
"""
return self._sysmon_probe_response_timeout
@sysmon_probe_response_timeout.setter
def sysmon_probe_response_timeout(self, value):
""" Set sysmon_probe_response_timeout value.
Notes:
Probe response timeout in seconds.
This attribute is named `sysmonProbeResponseTimeout` in VSD API.
"""
self._sysmon_probe_response_timeout = value
Ancestors (in MRO)
- NUSystemConfig
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_DOMAIN_TUNNEL_TYPE_DC_DEFAULT
var CONST_DOMAIN_TUNNEL_TYPE_GRE
var CONST_DOMAIN_TUNNEL_TYPE_VXLAN
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA1
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA256
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_AUTHENTICATION_ALGORITHM_HMAC_SHA512
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_128_CBC
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_AES_256_CBC
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEED_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_ENCRYPTION_ALGORITHM_RSA_1024
var CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA1WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA224WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA256WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA384WITHRSA
var CONST_GROUP_KEY_DEFAULT_SEK_PAYLOAD_SIGNING_ALGORITHM_SHA512WITHRSA
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_MD5
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA1
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA256
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA384
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_AUTHENTICATION_ALGORITHM_HMAC_SHA512
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_AES_128_CBC
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_AES_192_CBC
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_AES_256_CBC
var CONST_GROUP_KEY_DEFAULT_TRAFFIC_ENCRYPTION_ALGORITHM_TRIPLE_DES_CBC
var resource_name
var rest_name
Instance variables
var acl_allow_origin
Get acl_allow_origin value.
Notes: Defines the domains allowed for access control list.
This attribute is named `ACLAllowOrigin` in VSD API.
var ad_gateway_purge_time
Get ad_gateway_purge_time value.
Notes: Timers in sec for undefined vms to be deleted(min =7200, max = 86400).
This attribute is named `ADGatewayPurgeTime` in VSD API.
var alarms_max_per_object
Get alarms_max_per_object value.
Notes: Maximum alarms per object for example max distinct alarms for specific VM (min = 5, max =20)
This attribute is named `alarmsMaxPerObject` in VSD API.
var api_key_renewal_interval
Get api_key_renewal_interval value.
Notes: Defines the interval in seconds, before the expiry time, that can used to renew the apiKey by making me API call. Minimum value is 1 min and maximum is 5 min.
This attribute is named `APIKeyRenewalInterval` in VSD API.
var api_key_validity
Get api_key_validity value.
Notes: Defines the apiKey validity duration in seconds. Default is 24 hours and minimum value is 10 min.
This attribute is named `APIKeyValidity` in VSD API.
var as_number
Get as_number value.
Notes: Autonomous System Number,Used for RT/RD auto-generation
This attribute is named `ASNumber` in VSD API.
var avatar_base_path
Get avatar_base_path value.
Notes: Defines location where image files needs to be copied. Above URL should be configured to read the file from this location.
This attribute is named `avatarBasePath` in VSD API.
var avatar_base_url
Get avatar_base_url value.
Notes: Defines the url to read the avatar image files
This attribute is named `avatarBaseURL` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var customer_id_upper_limit
Get customer_id_upper_limit value.
Notes: Customer id upper limit, system wide value
This attribute is named `customerIDUpperLimit` in VSD API.
var customer_key
Get customer_key value.
Notes: Customer key associated with the licese
This attribute is named `customerKey` in VSD API.
var dhcp_option_size
Get dhcp_option_size value.
Notes: Defines total DHCP options that can be set on a domain.
This attribute is named `DHCPOptionSize` in VSD API.
var domain_tunnel_type
Get domain_tunnel_type value.
Notes: Default Domain Tunnel Type .Possible values are VXLAN,GRE Possible values are DC_DEFAULT, GRE, VXLAN, .
This attribute is named `domainTunnelType` in VSD API.
var dynamic_wan_service_diff_time
Get dynamic_wan_service_diff_time value.
Notes: Timers in sec for dynamic WAN Services to be considered not seen by 7X50.
This attribute is named `dynamicWANServiceDiffTime` in VSD API.
var ecmp_count
Get ecmp_count value.
Notes: System Default Equal-cost multi-path routing count,Every Domain derives ECMP count from this value unless specifically set for the domain
This attribute is named `ECMPCount` in VSD API.
var ejbca_nsg_certificate_profile
Get ejbca_nsg_certificate_profile value.
Notes: EJBCA NSG Certificate Profile
This attribute is named `ejbcaNSGCertificateProfile` in VSD API.
var ejbca_nsg_end_entity_profile
Get ejbca_nsg_end_entity_profile value.
Notes: EJBCA NSG End Entity Profile
This attribute is named `ejbcaNSGEndEntityProfile` in VSD API.
var ejbca_ocsp_responder_cn
Get ejbca_ocsp_responder_cn value.
Notes: EJBCA OCSP Responder CommonName
This attribute is named `ejbcaOCSPResponderCN` in VSD API.
var ejbca_ocsp_responder_uri
Get ejbca_ocsp_responder_uri value.
Notes: EJBCA OCSP Responder URI
This attribute is named `ejbcaOCSPResponderURI` in VSD API.
var ejbca_vsp_root_ca
Get ejbca_vsp_root_ca value.
Notes: EJBCA VSP CA
This attribute is named `ejbcaVspRootCa` in VSD API.
var elastic_cluster_name
Get elastic_cluster_name value.
Notes: Specifies the name of the Elastic Search Cluster.
This attribute is named `elasticClusterName` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var esi_id
Get esi_id value.
Notes: ESI ID offset
This attribute is named `esiID` in VSD API.
var event_log_cleanup_interval
Get event_log_cleanup_interval value.
Notes: Cleanup task run interval in seconds.
This attribute is named `eventLogCleanupInterval` in VSD API.
var event_log_entry_max_age
Get event_log_entry_max_age value.
Notes: Maximum age in days for cleanup of the eventlog entries. On every periodic interval run, any eventlog entries older than this max age will be deleted.
This attribute is named `eventLogEntryMaxAge` in VSD API.
var event_processor_interval
Get event_processor_interval value.
Notes: Defines time interval in milliseconds when events collected for a client should be processed.
This attribute is named `eventProcessorInterval` in VSD API.
var event_processor_max_events_count
Get event_processor_max_events_count value.
Notes: Defines the maximum number of events to be collected in case of events burst.
This attribute is named `eventProcessorMaxEventsCount` in VSD API.
var event_processor_timeout
Get event_processor_timeout value.
Notes: Defines the maximum time period in milliseconds for the Rest server to wait before sending the events from the system.
This attribute is named `eventProcessorTimeout` in VSD API.
var evpnbgp_community_tag_as_number
Get evpnbgp_community_tag_as_number value.
Notes: Autonomous System Number,Used for EVPNBGPCommunityTag auto-generation
This attribute is named `EVPNBGPCommunityTagASNumber` in VSD API.
var evpnbgp_community_tag_lower_limit
Get evpnbgp_community_tag_lower_limit value.
Notes: EVPNBGPCommunityTag lower limit
This attribute is named `EVPNBGPCommunityTagLowerLimit` in VSD API.
var evpnbgp_community_tag_upper_limit
Get evpnbgp_community_tag_upper_limit value.
Notes: EVPNBGPCommunityTag upper limit
This attribute is named `EVPNBGPCommunityTagUpperLimit` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var group_key_default_seed_generation_interval
Get group_key_default_seed_generation_interval value.
Notes: Group Key Encryption Profile Default Seed Generation Interval
This attribute is named `groupKeyDefaultSeedGenerationInterval` in VSD API.
var group_key_default_seed_lifetime
Get group_key_default_seed_lifetime value.
Notes: Group Key Encryption Profile Default Seed Lifetime
This attribute is named `groupKeyDefaultSeedLifetime` in VSD API.
var group_key_default_seed_payload_authentication_algorithm
Get group_key_default_seed_payload_authentication_algorithm value.
Notes: Group Key Encryption Profile Default Seed Payload Authentication Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadAuthenticationAlgorithm` in VSD API.
var group_key_default_seed_payload_encryption_algorithm
Get group_key_default_seed_payload_encryption_algorithm value.
Notes: Group Key Encryption Profile Default Seed Payload Encryption Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadEncryptionAlgorithm` in VSD API.
var group_key_default_seed_payload_signing_algorithm
Get group_key_default_seed_payload_signing_algorithm value.
Notes: Group Key Encryption Profile Default Seed Payload Signature Algorithm.
This attribute is named `groupKeyDefaultSeedPayloadSigningAlgorithm` in VSD API.
var group_key_default_sek_generation_interval
Get group_key_default_sek_generation_interval value.
Notes: Group Key Encryption Profile Default SEK Generation Interval
This attribute is named `groupKeyDefaultSEKGenerationInterval` in VSD API.
var group_key_default_sek_lifetime
Get group_key_default_sek_lifetime value.
Notes: Group Key Encryption Profile Default SEK Lifetime
This attribute is named `groupKeyDefaultSEKLifetime` in VSD API.
var group_key_default_sek_payload_encryption_algorithm
Get group_key_default_sek_payload_encryption_algorithm value.
Notes: Group Key Encryption Profile Default Sek Payload Encryption Algorithm.
This attribute is named `groupKeyDefaultSEKPayloadEncryptionAlgorithm` in VSD API.
var group_key_default_sek_payload_signing_algorithm
Get group_key_default_sek_payload_signing_algorithm value.
Notes: Group Key Encryption Profile Default Sek Payload Signing Algorithm.
This attribute is named `groupKeyDefaultSEKPayloadSigningAlgorithm` in VSD API.
var group_key_default_traffic_authentication_algorithm
Get group_key_default_traffic_authentication_algorithm value.
Notes: Group Key Encryption Profile Default Traffic Authentication Algorithm.
This attribute is named `groupKeyDefaultTrafficAuthenticationAlgorithm` in VSD API.
var group_key_default_traffic_encryption_algorithm
Get group_key_default_traffic_encryption_algorithm value.
Notes: Group Key Encryption Profile Default Traffic Encryption Algorithm.
This attribute is named `groupKeyDefaultTrafficEncryptionAlgorithm` in VSD API.
var group_key_default_traffic_encryption_key_lifetime
Get group_key_default_traffic_encryption_key_lifetime value.
Notes: Group Key Encryption Profile Default Traffic Encryption Key Lifetime
This attribute is named `groupKeyDefaultTrafficEncryptionKeyLifetime` in VSD API.
var group_key_generation_interval_on_forced_re_key
Get group_key_generation_interval_on_forced_re_key value.
Notes: Time in seconds before new keys will be generated in the case of a forced re-key event
This attribute is named `groupKeyGenerationIntervalOnForcedReKey` in VSD API.
var group_key_generation_interval_on_revoke
Get group_key_generation_interval_on_revoke value.
Notes: Time in seconds before new keys will be generated in the case of a revoke event
This attribute is named `groupKeyGenerationIntervalOnRevoke` in VSD API.
var group_key_minimum_seed_generation_interval
Get group_key_minimum_seed_generation_interval value.
Notes: Group Key Encryption Profile Default Seed Generation Interval
This attribute is named `groupKeyMinimumSeedGenerationInterval` in VSD API.
var group_key_minimum_seed_lifetime
Get group_key_minimum_seed_lifetime value.
Notes: Group Key Encryption Profile Default Seed Lifetime
This attribute is named `groupKeyMinimumSeedLifetime` in VSD API.
var group_key_minimum_sek_generation_interval
Get group_key_minimum_sek_generation_interval value.
Notes: Group Key Encryption Profile Minimum SEK Generation Interval
This attribute is named `groupKeyMinimumSEKGenerationInterval` in VSD API.
var group_key_minimum_sek_lifetime
Get group_key_minimum_sek_lifetime value.
Notes: Group Key Encryption Profile Minimum SEK Lifetime
This attribute is named `groupKeyMinimumSEKLifetime` in VSD API.
var group_key_minimum_traffic_encryption_key_lifetime
Get group_key_minimum_traffic_encryption_key_lifetime value.
Notes: Group Key Encryption Profile Minimum TEK Lifetime
This attribute is named `groupKeyMinimumTrafficEncryptionKeyLifetime` in VSD API.
var id
Get object id
var inactive_timeout
Get inactive_timeout value.
Notes: Defines the inactive timeout for the client. If the client is inactive for more than timeout, server clears off all the cache/information regarding the client. This value should be greater than event processor max timeout
This attribute is named `inactiveTimeout` in VSD API.
var key_server_monitor_enabled
Get key_server_monitor_enabled value.
Notes: Enable the keyserver debug monitor (ie. ksmon command)
This attribute is named `keyServerMonitorEnabled` in VSD API.
var key_server_vsd_data_synchronization_interval
Get key_server_vsd_data_synchronization_interval value.
Notes: KeyServer time in seconds between full resyncs of VSD data (just in case of missed events)
This attribute is named `keyServerVSDDataSynchronizationInterval` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var ldap_sync_interval
Get ldap_sync_interval value.
Notes: LDAP Sync-Up task interval in seconds.
This attribute is named `LDAPSyncInterval` in VSD API.
var ldap_trust_store_certifcate
Get ldap_trust_store_certifcate value.
Notes: Location of the truststore which is need to store LDAP server certificates. Default is cacerts located in java.home/lib/security/cacerts. Uncomment below setting if you need to use a different file
This attribute is named `LDAPTrustStoreCertifcate` in VSD API.
var ldap_trust_store_password
Get ldap_trust_store_password value.
Notes: Password to access the truststore. Uncomment below line to change its value.
This attribute is named `LDAPTrustStorePassword` in VSD API.
var local_id
Get local id
var lru_cache_size_per_subnet
Get lru_cache_size_per_subnet value.
Notes: LRU Map size per subnet (to hold the deleted vm's ip addresses).
This attribute is named `LRUCacheSizePerSubnet` in VSD API.
var max_failed_logins
Get max_failed_logins value.
Notes: Maximum failed login attempts before the account is locked (min = 5, max = 10). 0 = not enforced (unlimited attempts). This is not enforced if LDAP is used for authorization
This attribute is named `maxFailedLogins` in VSD API.
var max_response
Get max_response value.
Notes: Defines maximum results returned by the REST call (allowed max=5000).
This attribute is named `maxResponse` in VSD API.
var metadatas
var nsg_bootstrap_endpoint
Get nsg_bootstrap_endpoint value.
Notes: NSG Bootstrap Endpoint
This attribute is named `nsgBootstrapEndpoint` in VSD API.
var nsg_config_endpoint
Get nsg_config_endpoint value.
Notes: NSG Config Endpoint
This attribute is named `nsgConfigEndpoint` in VSD API.
var nsg_local_ui_url
Get nsg_local_ui_url value.
Notes: NSG Local UI URL - will be redirected on NSG to localhost
This attribute is named `nsgLocalUiUrl` in VSD API.
var offset_customer_id
Get offset_customer_id value.
Notes: Customer id offset, this value has to be set before jboss starts , after that any change of value is ignored (minexclusive = 0, max = 20000) system wide value
This attribute is named `offsetCustomerID` in VSD API.
var offset_service_id
Get offset_service_id value.
Notes: Service id offset, this value has to be set before jboss starts during install time, after that any change of value is ignored (minexclusive = 0, max = 40000) system wide value
This attribute is named `offsetServiceID` in VSD API.
var owner
Get owner
var page_max_size
Get page_max_size value.
Notes: Defines upper bound for the page size. Configured or input page size should be less than this max page size.
This attribute is named `pageMaxSize` in VSD API.
var page_size
Get page_size value.
Notes: Defines the page size for the results returned by the REST call.
This attribute is named `pageSize` in VSD API.
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var post_processor_threads_count
Get post_processor_threads_count value.
Notes: Post processor thread count.
This attribute is named `postProcessorThreadsCount` in VSD API.
var rd_lower_limit
Get rd_lower_limit value.
Notes: route distinguisher lower limit
This attribute is named `RDLowerLimit` in VSD API.
var rd_public_network_lower_limit
Get rd_public_network_lower_limit value.
Notes: route distinguisher public network lower limit
This attribute is named `RDPublicNetworkLowerLimit` in VSD API.
var rd_public_network_upper_limit
Get rd_public_network_upper_limit value.
Notes: route distinguisher public network upper limit
This attribute is named `RDPublicNetworkUpperLimit` in VSD API.
var rd_upper_limit
Get rd_upper_limit value.
Notes: route distinguisher upper limit
This attribute is named `RDUpperLimit` in VSD API.
var reflexive_acl_timeout
Get reflexive_acl_timeout value.
Notes: Defines the timeout in seconds for reflexive ACLs. This value applies for both TCP and UDP connections. Default value is 180 seconds and the timeout should be between 10 to 86400 seconds.
This attribute is named `reflexiveACLTimeout` in VSD API.
var rt_lower_limit
Get rt_lower_limit value.
Notes: route target lower limit
This attribute is named `RTLowerLimit` in VSD API.
var rt_public_network_lower_limit
Get rt_public_network_lower_limit value.
Notes: route target public network lower limit
This attribute is named `RTPublicNetworkLowerLimit` in VSD API.
var rt_public_network_upper_limit
Get rt_public_network_upper_limit value.
Notes: route target public network upper limit
This attribute is named `RTPublicNetworkUpperLimit` in VSD API.
var rt_upper_limit
Get rt_upper_limit value.
Notes: route target upper limit
This attribute is named `RTUpperLimit` in VSD API.
var service_id_upper_limit
Get service_id_upper_limit value.
Notes: Service id upper limit system wide value
This attribute is named `serviceIDUpperLimit` in VSD API.
var stack_trace_enabled
Get stack_trace_enabled value.
Notes: True to enable stacktrace in the REST call.
This attribute is named `stackTraceEnabled` in VSD API.
var static_wan_service_purge_time
Get static_wan_service_purge_time value.
Notes: Timers in sec for unreacheable static WAN Services to be deleted.
This attribute is named `staticWANServicePurgeTime` in VSD API.
var statistics_enabled
Get statistics_enabled value.
Notes: This flag is used to indicate if statistics is enabled in the system. CSProot is expected to activate this through the enable statistics script.
This attribute is named `statisticsEnabled` in VSD API.
var stats_collector_address
Get stats_collector_address value.
Notes: Specify the ip address(es) of the stats collector.
This attribute is named `statsCollectorAddress` in VSD API.
var stats_collector_port
Get stats_collector_port value.
Notes: Specify the port number(s) of the stats collector.
This attribute is named `statsCollectorPort` in VSD API.
var stats_collector_proto_buf_port
Get stats_collector_proto_buf_port value.
Notes: Specify the protobuf port number(s) of the stats collector.
This attribute is named `statsCollectorProtoBufPort` in VSD API.
var stats_max_data_points
Get stats_max_data_points value.
Notes: Specifies the maximum number of data points to support.
This attribute is named `statsMaxDataPoints` in VSD API.
var stats_min_duration
Get stats_min_duration value.
Notes: Default minimum duration for statistics to be displayed in UI is 30 days in seconds.
This attribute is named `statsMinDuration` in VSD API.
var stats_number_of_data_points
Get stats_number_of_data_points value.
Notes: Specifies number of data points.
This attribute is named `statsNumberOfDataPoints` in VSD API.
var stats_tsdb_server_address
Get stats_tsdb_server_address value.
Notes: Specifies the TSDB server location.
This attribute is named `statsTSDBServerAddress` in VSD API.
var subnet_resync_interval
Get subnet_resync_interval value.
Notes: After resync on a subnet , another resync on the same subnet is allowed based on the below value subnet resync complete wait time in min.
This attribute is named `subnetResyncInterval` in VSD API.
var subnet_resync_outstanding_interval
Get subnet_resync_outstanding_interval value.
Notes: Outstanding subnet resync interval (in secs). System wide value.
This attribute is named `subnetResyncOutstandingInterval` in VSD API.
var syslog_destination_host
Get syslog_destination_host value.
Notes: Specifies the remote syslog destination host
This attribute is named `syslogDestinationHost` in VSD API.
var syslog_destination_port
Get syslog_destination_port value.
Notes: Specified the remote syslog destination port
This attribute is named `syslogDestinationPort` in VSD API.
var sysmon_cleanup_task_interval
Get sysmon_cleanup_task_interval value.
Notes: Sysmon cleanup task run interval in seconds.
This attribute is named `sysmonCleanupTaskInterval` in VSD API.
var sysmon_node_presence_timeout
Get sysmon_node_presence_timeout value.
Notes: Node presence timeout in seconds if no messages.
This attribute is named `sysmonNodePresenceTimeout` in VSD API.
var sysmon_probe_response_timeout
Get sysmon_probe_response_timeout value.
Notes: Probe response timeout in seconds.
This attribute is named `sysmonProbeResponseTimeout` in VSD API.
var two_factor_code_expiry
Get two_factor_code_expiry value.
Notes: Two Factor Code Expiry in Seconds
This attribute is named `twoFactorCodeExpiry` in VSD API.
var two_factor_code_length
Get two_factor_code_length value.
Notes: Two Factor Code Length
This attribute is named `twoFactorCodeLength` in VSD API.
var two_factor_code_seed_length
Get two_factor_code_seed_length value.
Notes: Two Factor Seed length in bytes
This attribute is named `twoFactorCodeSeedLength` in VSD API.
var vm_cache_size
Get vm_cache_size value.
Notes: LRU Map size for vm, this value has to set based on memory given to VSD jvm not finalized.
This attribute is named `VMCacheSize` in VSD API.
var vm_purge_time
Get vm_purge_time value.
Notes: Timers in sec for undefined vms to be deleted.
This attribute is named `VMPurgeTime` in VSD API.
var vm_resync_deletion_wait_time
Get vm_resync_deletion_wait_time value.
Notes: After resync on vm , if no controller returns with a VM request with in the below timeframe then it will get deleted deletion wait time in minutes.
This attribute is named `VMResyncDeletionWaitTime` in VSD API.
var vm_resync_outstanding_interval
Get vm_resync_outstanding_interval value.
Notes: Outstanding VM resync interval (in secs). System wide value.
This attribute is named `VMResyncOutstandingInterval` in VSD API.
var vm_unreachable_cleanup_time
Get vm_unreachable_cleanup_time value.
Notes: Timers in sec for unreachable VMs for cleanup.
This attribute is named `VMUnreachableCleanupTime` in VSD API.
var vm_unreachable_time
Get vm_unreachable_time value.
Notes: Timers in sec for unreachable VMs.
This attribute is named `VMUnreachableTime` in VSD API.
var vnid_lower_limit
Get vnid_lower_limit value.
Notes: Virtual network ID offset
This attribute is named `VNIDLowerLimit` in VSD API.
var vnid_public_network_lower_limit
Get vnid_public_network_lower_limit value.
Notes: Virtual network ID public network lower limit
This attribute is named `VNIDPublicNetworkLowerLimit` in VSD API.
var vnid_public_network_upper_limit
Get vnid_public_network_upper_limit value.
Notes: Virtual network ID public network upper limit
This attribute is named `VNIDPublicNetworkUpperLimit` in VSD API.
var vnid_upper_limit
Get vnid_upper_limit value.
Notes: Virtual network ID upper limit
This attribute is named `VNIDUpperLimit` in VSD API.
var vsc_on_same_version_as_vsd
Get vsc_on_same_version_as_vsd value.
Notes: This flag is used to indicate that whether VSC is on the same version as VSD or not.
This attribute is named `VSCOnSameVersionAsVSD` in VSD API.
var vsd_read_only_mode
Get vsd_read_only_mode value.
Notes: True means VSD readonly mode enabled. False means VSD readonly mode disabled
This attribute is named `VSDReadOnlyMode` in VSD API.
var vsd_upgrade_is_complete
Get vsd_upgrade_is_complete value.
Notes: This flag is used to indicate that whether VSD upgrade is complete,it is expected that csproot will set to true,after VSD upgrade is complete and also making sure that all VSC's audits and Gateway audits with VSD are done
This attribute is named `VSDUpgradeIsComplete` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a SystemConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> systemconfig = NUSystemConfig(id=u'xxxx-xxx-xxx-xxx', name=u'SystemConfig') >>> systemconfig = NUSystemConfig(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a SystemConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> systemconfig = NUSystemConfig(id=u'xxxx-xxx-xxx-xxx', name=u'SystemConfig')
>>> systemconfig = NUSystemConfig(data=my_dict)
"""
super(NUSystemConfig, self).__init__()
# Read/Write Attributes
self._acl_allow_origin = None
self._ecmp_count = None
self._ldap_sync_interval = None
self._ldap_trust_store_certifcate = None
self._ldap_trust_store_password = None
self._ad_gateway_purge_time = None
self._rd_lower_limit = None
self._rd_public_network_lower_limit = None
self._rd_public_network_upper_limit = None
self._rd_upper_limit = None
self._dhcp_option_size = None
self._vm_cache_size = None
self._vm_purge_time = None
self._vm_resync_deletion_wait_time = None
self._vm_resync_outstanding_interval = None
self._vm_unreachable_cleanup_time = None
self._vm_unreachable_time = None
self._vnid_lower_limit = None
self._vnid_public_network_lower_limit = None
self._vnid_public_network_upper_limit = None
self._vnid_upper_limit = None
self._api_key_renewal_interval = None
self._api_key_validity = None
self._lru_cache_size_per_subnet = None
self._vsc_on_same_version_as_vsd = None
self._vsd_read_only_mode = None
self._vsd_upgrade_is_complete = None
self._as_number = None
self._rt_lower_limit = None
self._rt_public_network_lower_limit = None
self._rt_public_network_upper_limit = None
self._rt_upper_limit = None
self._evpnbgp_community_tag_as_number = None
self._evpnbgp_community_tag_lower_limit = None
self._evpnbgp_community_tag_upper_limit = None
self._page_max_size = None
self._page_size = None
self._last_updated_by = None
self._max_failed_logins = None
self._max_response = None
self._reflexive_acl_timeout = None
self._service_id_upper_limit = None
self._key_server_monitor_enabled = None
self._key_server_vsd_data_synchronization_interval = None
self._offset_customer_id = None
self._offset_service_id = None
self._ejbca_nsg_certificate_profile = None
self._ejbca_nsg_end_entity_profile = None
self._ejbca_ocsp_responder_cn = None
self._ejbca_ocsp_responder_uri = None
self._ejbca_vsp_root_ca = None
self._alarms_max_per_object = None
self._elastic_cluster_name = None
self._inactive_timeout = None
self._entity_scope = None
self._domain_tunnel_type = None
self._post_processor_threads_count = None
self._group_key_default_sek_generation_interval = None
self._group_key_default_sek_lifetime = None
self._group_key_default_sek_payload_encryption_algorithm = None
self._group_key_default_sek_payload_signing_algorithm = None
self._group_key_default_seed_generation_interval = None
self._group_key_default_seed_lifetime = None
self._group_key_default_seed_payload_authentication_algorithm = None
self._group_key_default_seed_payload_encryption_algorithm = None
self._group_key_default_seed_payload_signing_algorithm = None
self._group_key_default_traffic_authentication_algorithm = None
self._group_key_default_traffic_encryption_algorithm = None
self._group_key_default_traffic_encryption_key_lifetime = None
self._group_key_generation_interval_on_forced_re_key = None
self._group_key_generation_interval_on_revoke = None
self._group_key_minimum_sek_generation_interval = None
self._group_key_minimum_sek_lifetime = None
self._group_key_minimum_seed_generation_interval = None
self._group_key_minimum_seed_lifetime = None
self._group_key_minimum_traffic_encryption_key_lifetime = None
self._nsg_bootstrap_endpoint = None
self._nsg_config_endpoint = None
self._nsg_local_ui_url = None
self._esi_id = None
self._stack_trace_enabled = None
self._static_wan_service_purge_time = None
self._statistics_enabled = None
self._stats_collector_address = None
self._stats_collector_port = None
self._stats_collector_proto_buf_port = None
self._stats_max_data_points = None
self._stats_min_duration = None
self._stats_number_of_data_points = None
self._stats_tsdb_server_address = None
self._subnet_resync_interval = None
self._subnet_resync_outstanding_interval = None
self._customer_id_upper_limit = None
self._customer_key = None
self._avatar_base_path = None
self._avatar_base_url = None
self._event_log_cleanup_interval = None
self._event_log_entry_max_age = None
self._event_processor_interval = None
self._event_processor_max_events_count = None
self._event_processor_timeout = None
self._two_factor_code_expiry = None
self._two_factor_code_length = None
self._two_factor_code_seed_length = None
self._external_id = None
self._dynamic_wan_service_diff_time = None
self._syslog_destination_host = None
self._syslog_destination_port = None
self._sysmon_cleanup_task_interval = None
self._sysmon_node_presence_timeout = None
self._sysmon_probe_response_timeout = None
self.expose_attribute(local_name="acl_allow_origin", remote_name="ACLAllowOrigin", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ecmp_count", remote_name="ECMPCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ldap_sync_interval", remote_name="LDAPSyncInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ldap_trust_store_certifcate", remote_name="LDAPTrustStoreCertifcate", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ldap_trust_store_password", remote_name="LDAPTrustStorePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ad_gateway_purge_time", remote_name="ADGatewayPurgeTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_lower_limit", remote_name="RDLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_public_network_lower_limit", remote_name="RDPublicNetworkLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_public_network_upper_limit", remote_name="RDPublicNetworkUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rd_upper_limit", remote_name="RDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_option_size", remote_name="DHCPOptionSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_cache_size", remote_name="VMCacheSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_purge_time", remote_name="VMPurgeTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_resync_deletion_wait_time", remote_name="VMResyncDeletionWaitTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_resync_outstanding_interval", remote_name="VMResyncOutstandingInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_unreachable_cleanup_time", remote_name="VMUnreachableCleanupTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_unreachable_time", remote_name="VMUnreachableTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_lower_limit", remote_name="VNIDLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_public_network_lower_limit", remote_name="VNIDPublicNetworkLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_public_network_upper_limit", remote_name="VNIDPublicNetworkUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vnid_upper_limit", remote_name="VNIDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="api_key_renewal_interval", remote_name="APIKeyRenewalInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="api_key_validity", remote_name="APIKeyValidity", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="lru_cache_size_per_subnet", remote_name="LRUCacheSizePerSubnet", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsc_on_same_version_as_vsd", remote_name="VSCOnSameVersionAsVSD", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsd_read_only_mode", remote_name="VSDReadOnlyMode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsd_upgrade_is_complete", remote_name="VSDUpgradeIsComplete", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="as_number", remote_name="ASNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_lower_limit", remote_name="RTLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_public_network_lower_limit", remote_name="RTPublicNetworkLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_public_network_upper_limit", remote_name="RTPublicNetworkUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="rt_upper_limit", remote_name="RTUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="evpnbgp_community_tag_as_number", remote_name="EVPNBGPCommunityTagASNumber", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="evpnbgp_community_tag_lower_limit", remote_name="EVPNBGPCommunityTagLowerLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="evpnbgp_community_tag_upper_limit", remote_name="EVPNBGPCommunityTagUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="page_max_size", remote_name="pageMaxSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="page_size", remote_name="pageSize", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_failed_logins", remote_name="maxFailedLogins", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_response", remote_name="maxResponse", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="reflexive_acl_timeout", remote_name="reflexiveACLTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_id_upper_limit", remote_name="serviceIDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="key_server_monitor_enabled", remote_name="keyServerMonitorEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="key_server_vsd_data_synchronization_interval", remote_name="keyServerVSDDataSynchronizationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="offset_customer_id", remote_name="offsetCustomerID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="offset_service_id", remote_name="offsetServiceID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_nsg_certificate_profile", remote_name="ejbcaNSGCertificateProfile", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_nsg_end_entity_profile", remote_name="ejbcaNSGEndEntityProfile", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_ocsp_responder_cn", remote_name="ejbcaOCSPResponderCN", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_ocsp_responder_uri", remote_name="ejbcaOCSPResponderURI", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ejbca_vsp_root_ca", remote_name="ejbcaVspRootCa", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="alarms_max_per_object", remote_name="alarmsMaxPerObject", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="elastic_cluster_name", remote_name="elasticClusterName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="inactive_timeout", remote_name="inactiveTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_tunnel_type", remote_name="domainTunnelType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC_DEFAULT', u'GRE', u'VXLAN'])
self.expose_attribute(local_name="post_processor_threads_count", remote_name="postProcessorThreadsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_sek_generation_interval", remote_name="groupKeyDefaultSEKGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_sek_lifetime", remote_name="groupKeyDefaultSEKLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_sek_payload_encryption_algorithm", remote_name="groupKeyDefaultSEKPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'RSA_1024'])
self.expose_attribute(local_name="group_key_default_sek_payload_signing_algorithm", remote_name="groupKeyDefaultSEKPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="group_key_default_seed_generation_interval", remote_name="groupKeyDefaultSeedGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_seed_lifetime", remote_name="groupKeyDefaultSeedLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_default_seed_payload_authentication_algorithm", remote_name="groupKeyDefaultSeedPayloadAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA512'])
self.expose_attribute(local_name="group_key_default_seed_payload_encryption_algorithm", remote_name="groupKeyDefaultSeedPayloadEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="group_key_default_seed_payload_signing_algorithm", remote_name="groupKeyDefaultSeedPayloadSigningAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'SHA1withRSA', u'SHA224withRSA', u'SHA256withRSA', u'SHA384withRSA', u'SHA512withRSA'])
self.expose_attribute(local_name="group_key_default_traffic_authentication_algorithm", remote_name="groupKeyDefaultTrafficAuthenticationAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'HMAC_MD5', u'HMAC_SHA1', u'HMAC_SHA256', u'HMAC_SHA384', u'HMAC_SHA512'])
self.expose_attribute(local_name="group_key_default_traffic_encryption_algorithm", remote_name="groupKeyDefaultTrafficEncryptionAlgorithm", attribute_type=str, is_required=False, is_unique=False, choices=[u'AES_128_CBC', u'AES_192_CBC', u'AES_256_CBC', u'TRIPLE_DES_CBC'])
self.expose_attribute(local_name="group_key_default_traffic_encryption_key_lifetime", remote_name="groupKeyDefaultTrafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_generation_interval_on_forced_re_key", remote_name="groupKeyGenerationIntervalOnForcedReKey", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_generation_interval_on_revoke", remote_name="groupKeyGenerationIntervalOnRevoke", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_sek_generation_interval", remote_name="groupKeyMinimumSEKGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_sek_lifetime", remote_name="groupKeyMinimumSEKLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_seed_generation_interval", remote_name="groupKeyMinimumSeedGenerationInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_seed_lifetime", remote_name="groupKeyMinimumSeedLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="group_key_minimum_traffic_encryption_key_lifetime", remote_name="groupKeyMinimumTrafficEncryptionKeyLifetime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nsg_bootstrap_endpoint", remote_name="nsgBootstrapEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nsg_config_endpoint", remote_name="nsgConfigEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nsg_local_ui_url", remote_name="nsgLocalUiUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="esi_id", remote_name="esiID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stack_trace_enabled", remote_name="stackTraceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_wan_service_purge_time", remote_name="staticWANServicePurgeTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="statistics_enabled", remote_name="statisticsEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_address", remote_name="statsCollectorAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_port", remote_name="statsCollectorPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_collector_proto_buf_port", remote_name="statsCollectorProtoBufPort", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_max_data_points", remote_name="statsMaxDataPoints", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_min_duration", remote_name="statsMinDuration", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_number_of_data_points", remote_name="statsNumberOfDataPoints", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="stats_tsdb_server_address", remote_name="statsTSDBServerAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subnet_resync_interval", remote_name="subnetResyncInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="subnet_resync_outstanding_interval", remote_name="subnetResyncOutstandingInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="customer_id_upper_limit", remote_name="customerIDUpperLimit", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="customer_key", remote_name="customerKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_base_path", remote_name="avatarBasePath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_base_url", remote_name="avatarBaseURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_log_cleanup_interval", remote_name="eventLogCleanupInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_log_entry_max_age", remote_name="eventLogEntryMaxAge", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_processor_interval", remote_name="eventProcessorInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_processor_max_events_count", remote_name="eventProcessorMaxEventsCount", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="event_processor_timeout", remote_name="eventProcessorTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="two_factor_code_expiry", remote_name="twoFactorCodeExpiry", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="two_factor_code_length", remote_name="twoFactorCodeLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="two_factor_code_seed_length", remote_name="twoFactorCodeSeedLength", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="dynamic_wan_service_diff_time", remote_name="dynamicWANServiceDiffTime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="syslog_destination_host", remote_name="syslogDestinationHost", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="syslog_destination_port", remote_name="syslogDestinationPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sysmon_cleanup_task_interval", remote_name="sysmonCleanupTaskInterval", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sysmon_node_presence_timeout", remote_name="sysmonNodePresenceTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="sysmon_probe_response_timeout", remote_name="sysmonProbeResponseTimeout", attribute_type=int, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUTCA
Represents a TCA in the VSD
Notes: Provides the definition of the Threshold Control Alarms.
class NUTCA(NURESTObject):
""" Represents a TCA in the VSD
Notes:
Provides the definition of the Threshold Control Alarms.
"""
__rest_name__ = "tca"
__resource_name__ = "tcas"
## Constants
CONST_SCOPE_GLOBAL = "GLOBAL"
CONST_METRIC_PACKETS_IN_DROPPED = "PACKETS_IN_DROPPED"
CONST_TYPE_BREACH = "BREACH"
CONST_METRIC_PACKETS_OUT_ERROR = "PACKETS_OUT_ERROR"
CONST_METRIC_BYTES_OUT = "BYTES_OUT"
CONST_TYPE_ROLLING_AVERAGE = "ROLLING_AVERAGE"
CONST_METRIC_PACKETS_DROPPED_BY_RATE_LIMIT = "PACKETS_DROPPED_BY_RATE_LIMIT"
CONST_METRIC_BYTES_IN = "BYTES_IN"
CONST_METRIC_INGRESS_PACKET_COUNT = "INGRESS_PACKET_COUNT"
CONST_METRIC_EGRESS_BYTE_COUNT = "EGRESS_BYTE_COUNT"
CONST_SCOPE_LOCAL = "LOCAL"
CONST_METRIC_INGRESS_BYTE_COUNT = "INGRESS_BYTE_COUNT"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_METRIC_PACKETS_OUT_DROPPED = "PACKETS_OUT_DROPPED"
CONST_METRIC_PACKETS_IN = "PACKETS_IN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_METRIC_PACKETS_OUT = "PACKETS_OUT"
CONST_METRIC_EGRESS_PACKET_COUNT = "EGRESS_PACKET_COUNT"
CONST_METRIC_PACKETS_IN_ERROR = "PACKETS_IN_ERROR"
def __init__(self, **kwargs):
""" Initializes a TCA instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> tca = NUTCA(id=u'xxxx-xxx-xxx-xxx', name=u'TCA')
>>> tca = NUTCA(data=my_dict)
"""
super(NUTCA, self).__init__()
# Read/Write Attributes
self._url_end_point = None
self._name = None
self._last_updated_by = None
self._scope = None
self._period = None
self._description = None
self._metric = None
self._threshold = None
self._entity_scope = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="url_end_point", remote_name="URLEndPoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="scope", remote_name="scope", attribute_type=str, is_required=True, is_unique=False, choices=[u'GLOBAL', u'LOCAL'])
self.expose_attribute(local_name="period", remote_name="period", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metric", remote_name="metric", attribute_type=str, is_required=True, is_unique=False, choices=[u'BYTES_IN', u'BYTES_OUT', u'EGRESS_BYTE_COUNT', u'EGRESS_PACKET_COUNT', u'INGRESS_BYTE_COUNT', u'INGRESS_PACKET_COUNT', u'PACKETS_DROPPED_BY_RATE_LIMIT', u'PACKETS_IN', u'PACKETS_IN_DROPPED', u'PACKETS_IN_ERROR', u'PACKETS_OUT', u'PACKETS_OUT_DROPPED', u'PACKETS_OUT_ERROR'])
self.expose_attribute(local_name="threshold", remote_name="threshold", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'BREACH', u'ROLLING_AVERAGE'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def url_end_point(self):
""" Get url_end_point value.
Notes:
URL endpoint to post Alarm data to when TCA is triggered
This attribute is named `URLEndPoint` in VSD API.
"""
return self._url_end_point
@url_end_point.setter
def url_end_point(self, value):
""" Set url_end_point value.
Notes:
URL endpoint to post Alarm data to when TCA is triggered
This attribute is named `URLEndPoint` in VSD API.
"""
self._url_end_point = value
@property
def name(self):
""" Get name value.
Notes:
The name of the TCA
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
The name of the TCA
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def scope(self):
""" Get scope value.
Notes:
GLOBAL or LOCAL scope. Global refers to aggregate values across subnets, zones or domains. Local refers to traffic from/to individual VMs.
"""
return self._scope
@scope.setter
def scope(self, value):
""" Set scope value.
Notes:
GLOBAL or LOCAL scope. Global refers to aggregate values across subnets, zones or domains. Local refers to traffic from/to individual VMs.
"""
self._scope = value
@property
def period(self):
""" Get period value.
Notes:
The averaging period
"""
return self._period
@period.setter
def period(self, value):
""" Set period value.
Notes:
The averaging period
"""
self._period = value
@property
def description(self):
""" Get description value.
Notes:
Desription of the TCA
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Desription of the TCA
"""
self._description = value
@property
def metric(self):
""" Get metric value.
Notes:
The metric associated with the TCA.
"""
return self._metric
@metric.setter
def metric(self, value):
""" Set metric value.
Notes:
The metric associated with the TCA.
"""
self._metric = value
@property
def threshold(self):
""" Get threshold value.
Notes:
The threshold that must be exceeded before an alarm is issued
"""
return self._threshold
@threshold.setter
def threshold(self, value):
""" Set threshold value.
Notes:
The threshold that must be exceeded before an alarm is issued
"""
self._threshold = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
Rolling average or sequence of samples over the averaging period.
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
Rolling average or sequence of samples over the averaging period.
"""
self._type = value
Ancestors (in MRO)
- NUTCA
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_METRIC_BYTES_IN
var CONST_METRIC_BYTES_OUT
var CONST_METRIC_EGRESS_BYTE_COUNT
var CONST_METRIC_EGRESS_PACKET_COUNT
var CONST_METRIC_INGRESS_BYTE_COUNT
var CONST_METRIC_INGRESS_PACKET_COUNT
var CONST_METRIC_PACKETS_DROPPED_BY_RATE_LIMIT
var CONST_METRIC_PACKETS_IN
var CONST_METRIC_PACKETS_IN_DROPPED
var CONST_METRIC_PACKETS_IN_ERROR
var CONST_METRIC_PACKETS_OUT
var CONST_METRIC_PACKETS_OUT_DROPPED
var CONST_METRIC_PACKETS_OUT_ERROR
var CONST_SCOPE_GLOBAL
var CONST_SCOPE_LOCAL
var CONST_TYPE_BREACH
var CONST_TYPE_ROLLING_AVERAGE
var resource_name
var rest_name
Instance variables
var alarms
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Desription of the TCA
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var metric
Get metric value.
Notes: The metric associated with the TCA.
var name
Get name value.
Notes: The name of the TCA
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var period
Get period value.
Notes: The averaging period
var scope
Get scope value.
Notes: GLOBAL or LOCAL scope. Global refers to aggregate values across subnets, zones or domains. Local refers to traffic from/to individual VMs.
var threshold
Get threshold value.
Notes: The threshold that must be exceeded before an alarm is issued
var type
Get type value.
Notes: Rolling average or sequence of samples over the averaging period.
var url_end_point
Get url_end_point value.
Notes: URL endpoint to post Alarm data to when TCA is triggered
This attribute is named `URLEndPoint` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a TCA instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> tca = NUTCA(id=u'xxxx-xxx-xxx-xxx', name=u'TCA') >>> tca = NUTCA(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a TCA instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> tca = NUTCA(id=u'xxxx-xxx-xxx-xxx', name=u'TCA')
>>> tca = NUTCA(data=my_dict)
"""
super(NUTCA, self).__init__()
# Read/Write Attributes
self._url_end_point = None
self._name = None
self._last_updated_by = None
self._scope = None
self._period = None
self._description = None
self._metric = None
self._threshold = None
self._entity_scope = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="url_end_point", remote_name="URLEndPoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="scope", remote_name="scope", attribute_type=str, is_required=True, is_unique=False, choices=[u'GLOBAL', u'LOCAL'])
self.expose_attribute(local_name="period", remote_name="period", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metric", remote_name="metric", attribute_type=str, is_required=True, is_unique=False, choices=[u'BYTES_IN', u'BYTES_OUT', u'EGRESS_BYTE_COUNT', u'EGRESS_PACKET_COUNT', u'INGRESS_BYTE_COUNT', u'INGRESS_PACKET_COUNT', u'PACKETS_DROPPED_BY_RATE_LIMIT', u'PACKETS_IN', u'PACKETS_IN_DROPPED', u'PACKETS_IN_ERROR', u'PACKETS_OUT', u'PACKETS_OUT_DROPPED', u'PACKETS_OUT_ERROR'])
self.expose_attribute(local_name="threshold", remote_name="threshold", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'BREACH', u'ROLLING_AVERAGE'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUTier
Represents a Tier in the VSD
Notes: Tier represents a portion of an Application.
class NUTier(NURESTObject):
""" Represents a Tier in the VSD
Notes:
Tier represents a portion of an Application.
"""
__rest_name__ = "tier"
__resource_name__ = "tiers"
## Constants
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSP = "VSP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT = "VPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA = "METADATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_TYPE_NETWORK_MACRO = "NETWORK_MACRO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ALARM = "ALARM"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_TYPE_APPLICATION_EXTENDED_NETWORK = "APPLICATION_EXTENDED_NETWORK"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_JOB = "JOB"
CONST_TYPE_STANDARD = "STANDARD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
def __init__(self, **kwargs):
""" Initializes a Tier instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> tier = NUTier(id=u'xxxx-xxx-xxx-xxx', name=u'Tier')
>>> tier = NUTier(data=my_dict)
"""
super(NUTier, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._description = None
self._metadata = None
self._netmask = None
self._entity_scope = None
self._associated_application_id = None
self._associated_floating_ip_pool_id = None
self._associated_network_macro_id = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata", remote_name="metadata", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_pool_id", remote_name="associatedFloatingIPPoolID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_macro_id", remote_name="associatedNetworkMacroID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'APPLICATION', u'APPLICATION_EXTENDED_NETWORK', u'NETWORK_MACRO', u'STANDARD'])
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the application tier.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the application tier.
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
The IP address of the gateway for this tier.
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
The IP address of the gateway for this tier.
"""
self._gateway = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the tier defined.
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the tier defined.
"""
self._address = value
@property
def description(self):
""" Get description value.
Notes:
Description of the application tier.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the application tier.
"""
self._description = value
@property
def metadata(self):
""" Get metadata value.
Notes:
Metadata field to store tier related data.
"""
return self._metadata
@metadata.setter
def metadata(self, value):
""" Set metadata value.
Notes:
Metadata field to store tier related data.
"""
self._metadata = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask for the tier.
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask for the tier.
"""
self._netmask = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated network macro ID.
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated network macro ID.
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_floating_ip_pool_id(self):
""" Get associated_floating_ip_pool_id value.
Notes:
The associated floating IP Pool ID.
This attribute is named `associatedFloatingIPPoolID` in VSD API.
"""
return self._associated_floating_ip_pool_id
@associated_floating_ip_pool_id.setter
def associated_floating_ip_pool_id(self, value):
""" Set associated_floating_ip_pool_id value.
Notes:
The associated floating IP Pool ID.
This attribute is named `associatedFloatingIPPoolID` in VSD API.
"""
self._associated_floating_ip_pool_id = value
@property
def associated_network_macro_id(self):
""" Get associated_network_macro_id value.
Notes:
The associated network macro ID.
This attribute is named `associatedNetworkMacroID` in VSD API.
"""
return self._associated_network_macro_id
@associated_network_macro_id.setter
def associated_network_macro_id(self, value):
""" Set associated_network_macro_id value.
Notes:
The associated network macro ID.
This attribute is named `associatedNetworkMacroID` in VSD API.
"""
self._associated_network_macro_id = value
@property
def associated_network_object_id(self):
""" Get associated_network_object_id value.
Notes:
The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
return self._associated_network_object_id
@associated_network_object_id.setter
def associated_network_object_id(self, value):
""" Set associated_network_object_id value.
Notes:
The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
"""
self._associated_network_object_id = value
@property
def associated_network_object_type(self):
""" Get associated_network_object_type value.
Notes:
The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
return self._associated_network_object_type
@associated_network_object_type.setter
def associated_network_object_type(self, value):
""" Set associated_network_object_type value.
Notes:
The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
"""
self._associated_network_object_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
Type of the application tier.
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
Type of the application tier.
"""
self._type = value
Ancestors (in MRO)
- NUTier
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_USER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_NETWORK_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_TYPE_APPLICATION
var CONST_TYPE_APPLICATION_EXTENDED_NETWORK
var CONST_TYPE_NETWORK_MACRO
var CONST_TYPE_STANDARD
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the tier defined.
var associated_application_id
Get associated_application_id value.
Notes: The associated network macro ID.
This attribute is named `associatedApplicationID` in VSD API.
var associated_floating_ip_pool_id
Get associated_floating_ip_pool_id value.
Notes: The associated floating IP Pool ID.
This attribute is named `associatedFloatingIPPoolID` in VSD API.
var associated_network_macro_id
Get associated_network_macro_id value.
Notes: The associated network macro ID.
This attribute is named `associatedNetworkMacroID` in VSD API.
var associated_network_object_id
Get associated_network_object_id value.
Notes: The associated network object id.
This attribute is named `associatedNetworkObjectID` in VSD API.
var associated_network_object_type
Get associated_network_object_type value.
Notes: The associated network object type. Refer to API section for supported types.
This attribute is named `associatedNetworkObjectType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the application tier.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: The IP address of the gateway for this tier.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata
Get metadata value.
Notes: Metadata field to store tier related data.
var metadatas
var name
Get name value.
Notes: Name of the application tier.
var netmask
Get netmask value.
Notes: Netmask for the tier.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var statistics
var statistics_policies
var tcas
var type
Get type value.
Notes: Type of the application tier.
var vms
var vports
Methods
def __init__(
self, **kwargs)
Initializes a Tier instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> tier = NUTier(id=u'xxxx-xxx-xxx-xxx', name=u'Tier') >>> tier = NUTier(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Tier instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> tier = NUTier(id=u'xxxx-xxx-xxx-xxx', name=u'Tier')
>>> tier = NUTier(data=my_dict)
"""
super(NUTier, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._gateway = None
self._address = None
self._description = None
self._metadata = None
self._netmask = None
self._entity_scope = None
self._associated_application_id = None
self._associated_floating_ip_pool_id = None
self._associated_network_macro_id = None
self._associated_network_object_id = None
self._associated_network_object_type = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata", remote_name="metadata", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_pool_id", remote_name="associatedFloatingIPPoolID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_macro_id", remote_name="associatedNetworkMacroID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_id", remote_name="associatedNetworkObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_network_object_type", remote_name="associatedNetworkObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'APPLICATION', u'APPLICATION_EXTENDED_NETWORK', u'NETWORK_MACRO', u'STANDARD'])
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUUplinkRD
Represents a UplinkRD in the VSD
Notes: Represents a network port uplink route distinguisher value.
class NUUplinkRD(NURESTObject):
""" Represents a UplinkRD in the VSD
Notes:
Represents a network port uplink route distinguisher value.
"""
__rest_name__ = "uplinkroutedistinguisher"
__resource_name__ = "uplinkroutedistinguishers"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_UPLINK_TYPE_RD_PRIMARY1 = "RD_PRIMARY1"
CONST_UPLINK_TYPE_RD_SECONDARY2 = "RD_SECONDARY2"
CONST_UPLINK_TYPE_RD_SECONDARY1 = "RD_SECONDARY1"
CONST_UPLINK_TYPE_RD_PRIMARY2 = "RD_PRIMARY2"
def __init__(self, **kwargs):
""" Initializes a UplinkRD instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> uplinkrd = NUUplinkRD(id=u'xxxx-xxx-xxx-xxx', name=u'UplinkRD')
>>> uplinkrd = NUUplinkRD(data=my_dict)
"""
super(NUUplinkRD, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._entity_scope = None
self._route_distinguisher = None
self._uplink_type = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uplink_type", remote_name="uplinkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'RD_PRIMARY1', u'RD_PRIMARY2', u'RD_SECONDARY1', u'RD_SECONDARY2'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def route_distinguisher(self):
""" Get route_distinguisher value.
Notes:
The uplink route distinguisher value is used to identify which route packets should be flowing through with regards to having multiple network ports on the VRS/NSG.
This attribute is named `routeDistinguisher` in VSD API.
"""
return self._route_distinguisher
@route_distinguisher.setter
def route_distinguisher(self, value):
""" Set route_distinguisher value.
Notes:
The uplink route distinguisher value is used to identify which route packets should be flowing through with regards to having multiple network ports on the VRS/NSG.
This attribute is named `routeDistinguisher` in VSD API.
"""
self._route_distinguisher = value
@property
def uplink_type(self):
""" Get uplink_type value.
Notes:
Indicates the uplink type associated with the instance of Uplink Route Distinguisher.
This attribute is named `uplinkType` in VSD API.
"""
return self._uplink_type
@uplink_type.setter
def uplink_type(self, value):
""" Set uplink_type value.
Notes:
Indicates the uplink type associated with the instance of Uplink Route Distinguisher.
This attribute is named `uplinkType` in VSD API.
"""
self._uplink_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUUplinkRD
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_UPLINK_TYPE_RD_PRIMARY1
var CONST_UPLINK_TYPE_RD_PRIMARY2
var CONST_UPLINK_TYPE_RD_SECONDARY1
var CONST_UPLINK_TYPE_RD_SECONDARY2
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var route_distinguisher
Get route_distinguisher value.
Notes: The uplink route distinguisher value is used to identify which route packets should be flowing through with regards to having multiple network ports on the VRS/NSG.
This attribute is named `routeDistinguisher` in VSD API.
var uplink_type
Get uplink_type value.
Notes: Indicates the uplink type associated with the instance of Uplink Route Distinguisher.
This attribute is named `uplinkType` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a UplinkRD instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> uplinkrd = NUUplinkRD(id=u'xxxx-xxx-xxx-xxx', name=u'UplinkRD') >>> uplinkrd = NUUplinkRD(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a UplinkRD instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> uplinkrd = NUUplinkRD(id=u'xxxx-xxx-xxx-xxx', name=u'UplinkRD')
>>> uplinkrd = NUUplinkRD(data=my_dict)
"""
super(NUUplinkRD, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._entity_scope = None
self._route_distinguisher = None
self._uplink_type = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="route_distinguisher", remote_name="routeDistinguisher", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uplink_type", remote_name="uplinkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'RD_PRIMARY1', u'RD_PRIMARY2', u'RD_SECONDARY1', u'RD_SECONDARY2'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUUser
Represents a User in the VSD
Notes: Object that identifies the user functions.
class NUUser(NURESTObject):
""" Represents a User in the VSD
Notes:
Object that identifies the user functions.
"""
__rest_name__ = "user"
__resource_name__ = "users"
## Constants
CONST_MANAGEMENT_MODE_CMS = "CMS"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_AVATAR_TYPE_URL = "URL"
CONST_AVATAR_TYPE_COMPUTEDURL = "COMPUTEDURL"
CONST_AVATAR_TYPE_BASE64 = "BASE64"
CONST_MANAGEMENT_MODE_DEFAULT = "DEFAULT"
def __init__(self, **kwargs):
""" Initializes a User instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> user = NUUser(id=u'xxxx-xxx-xxx-xxx', name=u'User')
>>> user = NUUser(data=my_dict)
"""
super(NUUser, self).__init__()
# Read/Write Attributes
self._management_mode = None
self._password = None
self._last_name = None
self._last_updated_by = None
self._first_name = None
self._disabled = None
self._email = None
self._entity_scope = None
self._mobile_number = None
self._user_name = None
self._avatar_data = None
self._avatar_type = None
self._external_id = None
self.expose_attribute(local_name="management_mode", remote_name="managementMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'CMS', u'DEFAULT'])
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_name", remote_name="lastName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="first_name", remote_name="firstName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="disabled", remote_name="disabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="email", remote_name="email", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="mobile_number", remote_name="mobileNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="avatar_data", remote_name="avatarData", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_type", remote_name="avatarType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BASE64', u'COMPUTEDURL', u'URL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def management_mode(self):
""" Get management_mode value.
Notes:
Management mode of the user object - allows for override of external authorization and syncup
This attribute is named `managementMode` in VSD API.
"""
return self._management_mode
@management_mode.setter
def management_mode(self, value):
""" Set management_mode value.
Notes:
Management mode of the user object - allows for override of external authorization and syncup
This attribute is named `managementMode` in VSD API.
"""
self._management_mode = value
@property
def password(self):
""" Get password value.
Notes:
User password stored as a hash (SHA-1 encrpted)
"""
return self._password
@password.setter
def password(self, value):
""" Set password value.
Notes:
User password stored as a hash (SHA-1 encrpted)
"""
self._password = value
@property
def last_name(self):
""" Get last_name value.
Notes:
Last name of the user
This attribute is named `lastName` in VSD API.
"""
return self._last_name
@last_name.setter
def last_name(self, value):
""" Set last_name value.
Notes:
Last name of the user
This attribute is named `lastName` in VSD API.
"""
self._last_name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def first_name(self):
""" Get first_name value.
Notes:
First name of the user
This attribute is named `firstName` in VSD API.
"""
return self._first_name
@first_name.setter
def first_name(self, value):
""" Set first_name value.
Notes:
First name of the user
This attribute is named `firstName` in VSD API.
"""
self._first_name = value
@property
def disabled(self):
""" Get disabled value.
Notes:
Status of the user account; true=disabled, false=not disabled; default value = false
"""
return self._disabled
@disabled.setter
def disabled(self, value):
""" Set disabled value.
Notes:
Status of the user account; true=disabled, false=not disabled; default value = false
"""
self._disabled = value
@property
def email(self):
""" Get email value.
Notes:
Email address of the user
"""
return self._email
@email.setter
def email(self, value):
""" Set email value.
Notes:
Email address of the user
"""
self._email = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def mobile_number(self):
""" Get mobile_number value.
Notes:
Mobile Number of the user
This attribute is named `mobileNumber` in VSD API.
"""
return self._mobile_number
@mobile_number.setter
def mobile_number(self, value):
""" Set mobile_number value.
Notes:
Mobile Number of the user
This attribute is named `mobileNumber` in VSD API.
"""
self._mobile_number = value
@property
def user_name(self):
""" Get user_name value.
Notes:
Unique Username of the user. Valid characters are alphabets, numbers and hyphen( - ).
This attribute is named `userName` in VSD API.
"""
return self._user_name
@user_name.setter
def user_name(self, value):
""" Set user_name value.
Notes:
Unique Username of the user. Valid characters are alphabets, numbers and hyphen( - ).
This attribute is named `userName` in VSD API.
"""
self._user_name = value
@property
def avatar_data(self):
""" Get avatar_data value.
Notes:
URL to the avatar data associated with the enterprise. If the avatarType is URL then value of avatarData should an URL of the image. If the avatarType BASE64 then avatarData should be BASE64 encoded value of the image
This attribute is named `avatarData` in VSD API.
"""
return self._avatar_data
@avatar_data.setter
def avatar_data(self, value):
""" Set avatar_data value.
Notes:
URL to the avatar data associated with the enterprise. If the avatarType is URL then value of avatarData should an URL of the image. If the avatarType BASE64 then avatarData should be BASE64 encoded value of the image
This attribute is named `avatarData` in VSD API.
"""
self._avatar_data = value
@property
def avatar_type(self):
""" Get avatar_type value.
Notes:
Avatar type.
This attribute is named `avatarType` in VSD API.
"""
return self._avatar_type
@avatar_type.setter
def avatar_type(self, value):
""" Set avatar_type value.
Notes:
Avatar type.
This attribute is named `avatarType` in VSD API.
"""
self._avatar_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUUser
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_AVATAR_TYPE_BASE64
var CONST_AVATAR_TYPE_COMPUTEDURL
var CONST_AVATAR_TYPE_URL
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MANAGEMENT_MODE_CMS
var CONST_MANAGEMENT_MODE_DEFAULT
var resource_name
var rest_name
Instance variables
var avatar_data
Get avatar_data value.
Notes: URL to the avatar data associated with the enterprise. If the avatarType is URL then value of avatarData should an URL of the image. If the avatarType BASE64 then avatarData should be BASE64 encoded value of the image
This attribute is named `avatarData` in VSD API.
var avatar_type
Get avatar_type value.
Notes: Avatar type.
This attribute is named `avatarType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var disabled
Get disabled value.
Notes: Status of the user account; true=disabled, false=not disabled; default value = false
var email
Get email value.
Notes: Email address of the user
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var first_name
Get first_name value.
Notes: First name of the user
This attribute is named `firstName` in VSD API.
var global_metadatas
var groups
var id
Get object id
var last_name
Get last_name value.
Notes: Last name of the user
This attribute is named `lastName` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var management_mode
Get management_mode value.
Notes: Management mode of the user object - allows for override of external authorization and syncup
This attribute is named `managementMode` in VSD API.
var metadatas
var mobile_number
Get mobile_number value.
Notes: Mobile Number of the user
This attribute is named `mobileNumber` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var password
Get password value.
Notes: User password stored as a hash (SHA-1 encrpted)
var user_name
Get user_name value.
Notes: Unique Username of the user. Valid characters are alphabets, numbers and hyphen( - ).
This attribute is named `userName` in VSD API.
var vms
Methods
def __init__(
self, **kwargs)
Initializes a User instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> user = NUUser(id=u'xxxx-xxx-xxx-xxx', name=u'User') >>> user = NUUser(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a User instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> user = NUUser(id=u'xxxx-xxx-xxx-xxx', name=u'User')
>>> user = NUUser(data=my_dict)
"""
super(NUUser, self).__init__()
# Read/Write Attributes
self._management_mode = None
self._password = None
self._last_name = None
self._last_updated_by = None
self._first_name = None
self._disabled = None
self._email = None
self._entity_scope = None
self._mobile_number = None
self._user_name = None
self._avatar_data = None
self._avatar_type = None
self._external_id = None
self.expose_attribute(local_name="management_mode", remote_name="managementMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'CMS', u'DEFAULT'])
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_name", remote_name="lastName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="first_name", remote_name="firstName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="disabled", remote_name="disabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="email", remote_name="email", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="mobile_number", remote_name="mobileNumber", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="avatar_data", remote_name="avatarData", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="avatar_type", remote_name="avatarType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BASE64', u'COMPUTEDURL', u'URL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVCenter
Represents a VCenter in the VSD
Notes: Represents a VCenter.
class NUVCenter(NURESTObject):
""" Represents a VCenter in the VSD
Notes:
Represents a VCenter.
"""
__rest_name__ = "vcenter"
__resource_name__ = "vcenters"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VCenter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcenter = NUVCenter(id=u'xxxx-xxx-xxx-xxx', name=u'VCenter')
>>> vcenter = NUVCenter(data=my_dict)
"""
super(NUVCenter, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._password = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._host_level_management = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._ip_address = None
self._primary_nuage_controller = None
self._vrs_config_id = None
self._vrs_password = None
self._vrs_user_name = None
self._user_name = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._http_port = None
self._https_port = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._auto_resolve_frequency = None
self._ovf_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="host_level_management", remote_name="hostLevelManagement", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="ipAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_config_id", remote_name="vrsConfigID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="http_port", remote_name="httpPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="https_port", remote_name="httpsPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_resolve_frequency", remote_name="autoResolveFrequency", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ovf_url", remote_name="ovfURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.vcenter_data_centers = NUVCenterDataCentersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def arp_reply(self):
""" Get arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
return self._arp_reply
@arp_reply.setter
def arp_reply(self, value):
""" Set arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
self._arp_reply = value
@property
def v_require_nuage_metadata(self):
""" Get v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
return self._v_require_nuage_metadata
@v_require_nuage_metadata.setter
def v_require_nuage_metadata(self, value):
""" Set v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
self._v_require_nuage_metadata = value
@property
def name(self):
""" Get name value.
Notes:
Name of the VCenter
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the VCenter
"""
self._name = value
@property
def password(self):
""" Get password value.
Notes:
Password for the VCenter user
"""
return self._password
@password.setter
def password(self, value):
""" Set password value.
Notes:
Password for the VCenter user
"""
self._password = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data_dns1(self):
""" Get data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
return self._data_dns1
@data_dns1.setter
def data_dns1(self, value):
""" Set data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
self._data_dns1 = value
@property
def data_dns2(self):
""" Get data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
return self._data_dns2
@data_dns2.setter
def data_dns2(self, value):
""" Set data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
self._data_dns2 = value
@property
def data_gateway(self):
""" Get data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
return self._data_gateway
@data_gateway.setter
def data_gateway(self, value):
""" Set data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
self._data_gateway = value
@property
def data_network_portgroup(self):
""" Get data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
return self._data_network_portgroup
@data_network_portgroup.setter
def data_network_portgroup(self, value):
""" Set data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
self._data_network_portgroup = value
@property
def datapath_sync_timeout(self):
""" Get datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
return self._datapath_sync_timeout
@datapath_sync_timeout.setter
def datapath_sync_timeout(self, value):
""" Set datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
self._datapath_sync_timeout = value
@property
def secondary_nuage_controller(self):
""" Get secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
return self._secondary_nuage_controller
@secondary_nuage_controller.setter
def secondary_nuage_controller(self, value):
""" Set secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
self._secondary_nuage_controller = value
@property
def generic_split_activation(self):
""" Get generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
return self._generic_split_activation
@generic_split_activation.setter
def generic_split_activation(self, value):
""" Set generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
self._generic_split_activation = value
@property
def separate_data_network(self):
""" Get separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
return self._separate_data_network
@separate_data_network.setter
def separate_data_network(self, value):
""" Set separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
self._separate_data_network = value
@property
def personality(self):
""" Get personality value.
Notes:
VRS/VRS-G
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
VRS/VRS-G
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
Description of the VCenter
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the VCenter
"""
self._description = value
@property
def metadata_server_ip(self):
""" Get metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
return self._metadata_server_ip
@metadata_server_ip.setter
def metadata_server_ip(self, value):
""" Set metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
self._metadata_server_ip = value
@property
def metadata_server_listen_port(self):
""" Get metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
return self._metadata_server_listen_port
@metadata_server_listen_port.setter
def metadata_server_listen_port(self, value):
""" Set metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
self._metadata_server_listen_port = value
@property
def metadata_server_port(self):
""" Get metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
return self._metadata_server_port
@metadata_server_port.setter
def metadata_server_port(self, value):
""" Set metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
self._metadata_server_port = value
@property
def metadata_service_enabled(self):
""" Get metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
return self._metadata_service_enabled
@metadata_service_enabled.setter
def metadata_service_enabled(self, value):
""" Set metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
self._metadata_service_enabled = value
@property
def network_uplink_interface(self):
""" Get network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
return self._network_uplink_interface
@network_uplink_interface.setter
def network_uplink_interface(self, value):
""" Set network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
self._network_uplink_interface = value
@property
def network_uplink_interface_gateway(self):
""" Get network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
return self._network_uplink_interface_gateway
@network_uplink_interface_gateway.setter
def network_uplink_interface_gateway(self, value):
""" Set network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
self._network_uplink_interface_gateway = value
@property
def network_uplink_interface_ip(self):
""" Get network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
return self._network_uplink_interface_ip
@network_uplink_interface_ip.setter
def network_uplink_interface_ip(self, value):
""" Set network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
self._network_uplink_interface_ip = value
@property
def network_uplink_interface_netmask(self):
""" Get network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
return self._network_uplink_interface_netmask
@network_uplink_interface_netmask.setter
def network_uplink_interface_netmask(self, value):
""" Set network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
self._network_uplink_interface_netmask = value
@property
def nfs_log_server(self):
""" Get nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
return self._nfs_log_server
@nfs_log_server.setter
def nfs_log_server(self, value):
""" Set nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
self._nfs_log_server = value
@property
def nfs_mount_path(self):
""" Get nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
return self._nfs_mount_path
@nfs_mount_path.setter
def nfs_mount_path(self, value):
""" Set nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
self._nfs_mount_path = value
@property
def mgmt_dns1(self):
""" Get mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
return self._mgmt_dns1
@mgmt_dns1.setter
def mgmt_dns1(self, value):
""" Set mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
self._mgmt_dns1 = value
@property
def mgmt_dns2(self):
""" Get mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
return self._mgmt_dns2
@mgmt_dns2.setter
def mgmt_dns2(self, value):
""" Set mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
self._mgmt_dns2 = value
@property
def mgmt_gateway(self):
""" Get mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
return self._mgmt_gateway
@mgmt_gateway.setter
def mgmt_gateway(self, value):
""" Set mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
self._mgmt_gateway = value
@property
def mgmt_network_portgroup(self):
""" Get mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
return self._mgmt_network_portgroup
@mgmt_network_portgroup.setter
def mgmt_network_portgroup(self, value):
""" Set mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
self._mgmt_network_portgroup = value
@property
def dhcp_relay_server(self):
""" Get dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
return self._dhcp_relay_server
@dhcp_relay_server.setter
def dhcp_relay_server(self, value):
""" Set dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
self._dhcp_relay_server = value
@property
def site_id(self):
""" Get site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
return self._site_id
@site_id.setter
def site_id(self, value):
""" Set site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
self._site_id = value
@property
def allow_data_dhcp(self):
""" Get allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
return self._allow_data_dhcp
@allow_data_dhcp.setter
def allow_data_dhcp(self, value):
""" Set allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
self._allow_data_dhcp = value
@property
def allow_mgmt_dhcp(self):
""" Get allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
return self._allow_mgmt_dhcp
@allow_mgmt_dhcp.setter
def allow_mgmt_dhcp(self, value):
""" Set allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
self._allow_mgmt_dhcp = value
@property
def flow_eviction_threshold(self):
""" Get flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
return self._flow_eviction_threshold
@flow_eviction_threshold.setter
def flow_eviction_threshold(self, value):
""" Set flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
self._flow_eviction_threshold = value
@property
def vm_network_portgroup(self):
""" Get vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
return self._vm_network_portgroup
@vm_network_portgroup.setter
def vm_network_portgroup(self, value):
""" Set vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
self._vm_network_portgroup = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def portgroup_metadata(self):
""" Get portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
return self._portgroup_metadata
@portgroup_metadata.setter
def portgroup_metadata(self, value):
""" Set portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
self._portgroup_metadata = value
@property
def host_level_management(self):
""" Get host_level_management value.
Notes:
Flag to say if host level management is enabled
This attribute is named `hostLevelManagement` in VSD API.
"""
return self._host_level_management
@host_level_management.setter
def host_level_management(self, value):
""" Set host_level_management value.
Notes:
Flag to say if host level management is enabled
This attribute is named `hostLevelManagement` in VSD API.
"""
self._host_level_management = value
@property
def nova_client_version(self):
""" Get nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
return self._nova_client_version
@nova_client_version.setter
def nova_client_version(self, value):
""" Set nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
self._nova_client_version = value
@property
def nova_metadata_service_auth_url(self):
""" Get nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
return self._nova_metadata_service_auth_url
@nova_metadata_service_auth_url.setter
def nova_metadata_service_auth_url(self, value):
""" Set nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
self._nova_metadata_service_auth_url = value
@property
def nova_metadata_service_endpoint(self):
""" Get nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
return self._nova_metadata_service_endpoint
@nova_metadata_service_endpoint.setter
def nova_metadata_service_endpoint(self, value):
""" Set nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
self._nova_metadata_service_endpoint = value
@property
def nova_metadata_service_password(self):
""" Get nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
return self._nova_metadata_service_password
@nova_metadata_service_password.setter
def nova_metadata_service_password(self, value):
""" Set nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
self._nova_metadata_service_password = value
@property
def nova_metadata_service_tenant(self):
""" Get nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
return self._nova_metadata_service_tenant
@nova_metadata_service_tenant.setter
def nova_metadata_service_tenant(self, value):
""" Set nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
self._nova_metadata_service_tenant = value
@property
def nova_metadata_service_username(self):
""" Get nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
return self._nova_metadata_service_username
@nova_metadata_service_username.setter
def nova_metadata_service_username(self, value):
""" Set nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
self._nova_metadata_service_username = value
@property
def nova_metadata_shared_secret(self):
""" Get nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
return self._nova_metadata_shared_secret
@nova_metadata_shared_secret.setter
def nova_metadata_shared_secret(self, value):
""" Set nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
self._nova_metadata_shared_secret = value
@property
def nova_region_name(self):
""" Get nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
return self._nova_region_name
@nova_region_name.setter
def nova_region_name(self, value):
""" Set nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
self._nova_region_name = value
@property
def ip_address(self):
""" Get ip_address value.
Notes:
IP Address of the VCenter
This attribute is named `ipAddress` in VSD API.
"""
return self._ip_address
@ip_address.setter
def ip_address(self, value):
""" Set ip_address value.
Notes:
IP Address of the VCenter
This attribute is named `ipAddress` in VSD API.
"""
self._ip_address = value
@property
def primary_nuage_controller(self):
""" Get primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
return self._primary_nuage_controller
@primary_nuage_controller.setter
def primary_nuage_controller(self, value):
""" Set primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
self._primary_nuage_controller = value
@property
def vrs_config_id(self):
""" Get vrs_config_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `vrsConfigID` in VSD API.
"""
return self._vrs_config_id
@vrs_config_id.setter
def vrs_config_id(self, value):
""" Set vrs_config_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `vrsConfigID` in VSD API.
"""
self._vrs_config_id = value
@property
def vrs_password(self):
""" Get vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
return self._vrs_password
@vrs_password.setter
def vrs_password(self, value):
""" Set vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
self._vrs_password = value
@property
def vrs_user_name(self):
""" Get vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
return self._vrs_user_name
@vrs_user_name.setter
def vrs_user_name(self, value):
""" Set vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
self._vrs_user_name = value
@property
def user_name(self):
""" Get user_name value.
Notes:
User name of the VCenter
This attribute is named `userName` in VSD API.
"""
return self._user_name
@user_name.setter
def user_name(self, value):
""" Set user_name value.
Notes:
User name of the VCenter
This attribute is named `userName` in VSD API.
"""
self._user_name = value
@property
def static_route(self):
""" Get static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
return self._static_route
@static_route.setter
def static_route(self, value):
""" Set static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
self._static_route = value
@property
def static_route_gateway(self):
""" Get static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
return self._static_route_gateway
@static_route_gateway.setter
def static_route_gateway(self, value):
""" Set static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
self._static_route_gateway = value
@property
def static_route_netmask(self):
""" Get static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
return self._static_route_netmask
@static_route_netmask.setter
def static_route_netmask(self, value):
""" Set static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
self._static_route_netmask = value
@property
def ntp_server1(self):
""" Get ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
return self._ntp_server1
@ntp_server1.setter
def ntp_server1(self, value):
""" Set ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
self._ntp_server1 = value
@property
def ntp_server2(self):
""" Get ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
return self._ntp_server2
@ntp_server2.setter
def ntp_server2(self, value):
""" Set ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
self._ntp_server2 = value
@property
def http_port(self):
""" Get http_port value.
Notes:
Http proxy port for VCenter
This attribute is named `httpPort` in VSD API.
"""
return self._http_port
@http_port.setter
def http_port(self, value):
""" Set http_port value.
Notes:
Http proxy port for VCenter
This attribute is named `httpPort` in VSD API.
"""
self._http_port = value
@property
def https_port(self):
""" Get https_port value.
Notes:
Https proxy port of the VCenter
This attribute is named `httpsPort` in VSD API.
"""
return self._https_port
@https_port.setter
def https_port(self, value):
""" Set https_port value.
Notes:
Https proxy port of the VCenter
This attribute is named `httpsPort` in VSD API.
"""
self._https_port = value
@property
def mtu(self):
""" Get mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
return self._mtu
@mtu.setter
def mtu(self, value):
""" Set mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
self._mtu = value
@property
def multi_vmssupport(self):
""" Get multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
return self._multi_vmssupport
@multi_vmssupport.setter
def multi_vmssupport(self, value):
""" Set multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
self._multi_vmssupport = value
@property
def multicast_receive_interface(self):
""" Get multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
return self._multicast_receive_interface
@multicast_receive_interface.setter
def multicast_receive_interface(self, value):
""" Set multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
self._multicast_receive_interface = value
@property
def multicast_receive_interface_ip(self):
""" Get multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
return self._multicast_receive_interface_ip
@multicast_receive_interface_ip.setter
def multicast_receive_interface_ip(self, value):
""" Set multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
self._multicast_receive_interface_ip = value
@property
def multicast_receive_interface_netmask(self):
""" Get multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
return self._multicast_receive_interface_netmask
@multicast_receive_interface_netmask.setter
def multicast_receive_interface_netmask(self, value):
""" Set multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
self._multicast_receive_interface_netmask = value
@property
def multicast_receive_range(self):
""" Get multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
return self._multicast_receive_range
@multicast_receive_range.setter
def multicast_receive_range(self, value):
""" Set multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
self._multicast_receive_range = value
@property
def multicast_send_interface(self):
""" Get multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
return self._multicast_send_interface
@multicast_send_interface.setter
def multicast_send_interface(self, value):
""" Set multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
self._multicast_send_interface = value
@property
def multicast_send_interface_ip(self):
""" Get multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
return self._multicast_send_interface_ip
@multicast_send_interface_ip.setter
def multicast_send_interface_ip(self, value):
""" Set multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
self._multicast_send_interface_ip = value
@property
def multicast_send_interface_netmask(self):
""" Get multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
return self._multicast_send_interface_netmask
@multicast_send_interface_netmask.setter
def multicast_send_interface_netmask(self, value):
""" Set multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
self._multicast_send_interface_netmask = value
@property
def multicast_source_portgroup(self):
""" Get multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
return self._multicast_source_portgroup
@multicast_source_portgroup.setter
def multicast_source_portgroup(self, value):
""" Set multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
self._multicast_source_portgroup = value
@property
def customized_script_url(self):
""" Get customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
return self._customized_script_url
@customized_script_url.setter
def customized_script_url(self, value):
""" Set customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
self._customized_script_url = value
@property
def auto_resolve_frequency(self):
""" Get auto_resolve_frequency value.
Notes:
Frequency at which VCenter issues are to be resolved
This attribute is named `autoResolveFrequency` in VSD API.
"""
return self._auto_resolve_frequency
@auto_resolve_frequency.setter
def auto_resolve_frequency(self, value):
""" Set auto_resolve_frequency value.
Notes:
Frequency at which VCenter issues are to be resolved
This attribute is named `autoResolveFrequency` in VSD API.
"""
self._auto_resolve_frequency = value
@property
def ovf_url(self):
""" Get ovf_url value.
Notes:
The url for the ovf
This attribute is named `ovfURL` in VSD API.
"""
return self._ovf_url
@ovf_url.setter
def ovf_url(self, value):
""" Set ovf_url value.
Notes:
The url for the ovf
This attribute is named `ovfURL` in VSD API.
"""
self._ovf_url = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVCenter
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var allow_data_dhcp
Get allow_data_dhcp value.
Notes: Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
var allow_mgmt_dhcp
Get allow_mgmt_dhcp value.
Notes: Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
var arp_reply
Get arp_reply value.
Notes: Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
var auto_resolve_frequency
Get auto_resolve_frequency value.
Notes: Frequency at which VCenter issues are to be resolved
This attribute is named `autoResolveFrequency` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var customized_script_url
Get customized_script_url value.
Notes: To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
var data_dns1
Get data_dns1 value.
Notes: Data DNS 1
This attribute is named `dataDNS1` in VSD API.
var data_dns2
Get data_dns2 value.
Notes: Data DNS 2
This attribute is named `dataDNS2` in VSD API.
var data_gateway
Get data_gateway value.
Notes: Data Gateway
This attribute is named `dataGateway` in VSD API.
var data_network_portgroup
Get data_network_portgroup value.
Notes: Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
var datapath_sync_timeout
Get datapath_sync_timeout value.
Notes: Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
var description
Get description value.
Notes: Description of the VCenter
var dhcp_relay_server
Get dhcp_relay_server value.
Notes: To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_eviction_threshold
Get flow_eviction_threshold value.
Notes: Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
var generic_split_activation
Get generic_split_activation value.
Notes: Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
var global_metadatas
var host_level_management
Get host_level_management value.
Notes: Flag to say if host level management is enabled
This attribute is named `hostLevelManagement` in VSD API.
var http_port
Get http_port value.
Notes: Http proxy port for VCenter
This attribute is named `httpPort` in VSD API.
var https_port
Get https_port value.
Notes: Https proxy port of the VCenter
This attribute is named `httpsPort` in VSD API.
var id
Get object id
var ip_address
Get ip_address value.
Notes: IP Address of the VCenter
This attribute is named `ipAddress` in VSD API.
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_server_ip
Get metadata_server_ip value.
Notes: Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
var metadata_server_listen_port
Get metadata_server_listen_port value.
Notes: Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
var metadata_server_port
Get metadata_server_port value.
Notes: Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
var metadata_service_enabled
Get metadata_service_enabled value.
Notes: Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
var metadatas
var mgmt_dns1
Get mgmt_dns1 value.
Notes: DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
var mgmt_dns2
Get mgmt_dns2 value.
Notes: DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
var mgmt_gateway
Get mgmt_gateway value.
Notes: Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
var mgmt_network_portgroup
Get mgmt_network_portgroup value.
Notes: Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
var mtu
Get mtu value.
Notes: Maximum Transmission Unit for eth2 interface
var multi_vmssupport
Get multi_vmssupport value.
Notes: Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
var multicast_receive_interface
Get multicast_receive_interface value.
Notes: Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
var multicast_receive_interface_ip
Get multicast_receive_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
var multicast_receive_interface_netmask
Get multicast_receive_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
var multicast_receive_range
Get multicast_receive_range value.
Notes: Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
var multicast_send_interface
Get multicast_send_interface value.
Notes: Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
var multicast_send_interface_ip
Get multicast_send_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
var multicast_send_interface_netmask
Get multicast_send_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
var multicast_source_portgroup
Get multicast_source_portgroup value.
Notes: Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
var name
Get name value.
Notes: Name of the VCenter
var network_uplink_interface
Get network_uplink_interface value.
Notes: Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
var network_uplink_interface_gateway
Get network_uplink_interface_gateway value.
Notes: Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
var network_uplink_interface_ip
Get network_uplink_interface_ip value.
Notes: Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
var network_uplink_interface_netmask
Get network_uplink_interface_netmask value.
Notes: Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
var nfs_log_server
Get nfs_log_server value.
Notes: IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
var nfs_mount_path
Get nfs_mount_path value.
Notes: Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
var nova_client_version
Get nova_client_version value.
Notes: Nova client Version
This attribute is named `novaClientVersion` in VSD API.
var nova_metadata_service_auth_url
Get nova_metadata_service_auth_url value.
Notes: Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
var nova_metadata_service_endpoint
Get nova_metadata_service_endpoint value.
Notes: Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
var nova_metadata_service_password
Get nova_metadata_service_password value.
Notes: Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
var nova_metadata_service_tenant
Get nova_metadata_service_tenant value.
Notes: Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
var nova_metadata_service_username
Get nova_metadata_service_username value.
Notes: Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
Get nova_metadata_shared_secret value.
Notes: Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
var nova_region_name
Get nova_region_name value.
Notes: Nova region name
This attribute is named `novaRegionName` in VSD API.
var ntp_server1
Get ntp_server1 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
var ntp_server2
Get ntp_server2 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
var ovf_url
Get ovf_url value.
Notes: The url for the ovf
This attribute is named `ovfURL` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var password
Get password value.
Notes: Password for the VCenter user
var personality
Get personality value.
Notes: VRS/VRS-G
var portgroup_metadata
Get portgroup_metadata value.
Notes: Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
var primary_nuage_controller
Get primary_nuage_controller value.
Notes: IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
var secondary_nuage_controller
Get secondary_nuage_controller value.
Notes: IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
var separate_data_network
Get separate_data_network value.
Notes: Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
var site_id
Get site_id value.
Notes: Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
var static_route
Get static_route value.
Notes: static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
var static_route_gateway
Get static_route_gateway value.
Notes: Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
var static_route_netmask
Get static_route_netmask value.
Notes: Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
var user_name
Get user_name value.
Notes: User name of the VCenter
This attribute is named `userName` in VSD API.
var v_require_nuage_metadata
Get v_require_nuage_metadata value.
Notes: Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
var vcenter_data_centers
var vm_network_portgroup
Get vm_network_portgroup value.
Notes: VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
var vrs_address_ranges
var vrs_config_id
Get vrs_config_id value.
Notes: The ID of the template that this Port was created from
This attribute is named `vrsConfigID` in VSD API.
var vrs_password
Get vrs_password value.
Notes: VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
var vrs_user_name
Get vrs_user_name value.
Notes: VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VCenter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vcenter = NUVCenter(id=u'xxxx-xxx-xxx-xxx', name=u'VCenter') >>> vcenter = NUVCenter(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VCenter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcenter = NUVCenter(id=u'xxxx-xxx-xxx-xxx', name=u'VCenter')
>>> vcenter = NUVCenter(data=my_dict)
"""
super(NUVCenter, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._password = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._host_level_management = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._ip_address = None
self._primary_nuage_controller = None
self._vrs_config_id = None
self._vrs_password = None
self._vrs_user_name = None
self._user_name = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._http_port = None
self._https_port = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._auto_resolve_frequency = None
self._ovf_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="password", remote_name="password", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="host_level_management", remote_name="hostLevelManagement", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="ipAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_config_id", remote_name="vrsConfigID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="http_port", remote_name="httpPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="https_port", remote_name="httpsPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="auto_resolve_frequency", remote_name="autoResolveFrequency", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="ovf_url", remote_name="ovfURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.vcenter_data_centers = NUVCenterDataCentersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVCenterCluster
Represents a VCenterCluster in the VSD
Notes: VCenter Clusters.
class NUVCenterCluster(NURESTObject):
""" Represents a VCenterCluster in the VSD
Notes:
VCenter Clusters.
"""
__rest_name__ = "vcentercluster"
__resource_name__ = "vcenterclusters"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VCenterCluster instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcentercluster = NUVCenterCluster(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterCluster')
>>> vcentercluster = NUVCenterCluster(data=my_dict)
"""
super(NUVCenterCluster, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_password = None
self._vrs_user_name = None
self._assoc_vcenter_data_center_id = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_vcenter_data_center_id", remote_name="assocVCenterDataCenterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.vcenter_hypervisors = NUVCenterHypervisorsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def arp_reply(self):
""" Get arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
return self._arp_reply
@arp_reply.setter
def arp_reply(self, value):
""" Set arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
self._arp_reply = value
@property
def v_require_nuage_metadata(self):
""" Get v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
return self._v_require_nuage_metadata
@v_require_nuage_metadata.setter
def v_require_nuage_metadata(self, value):
""" Set v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
self._v_require_nuage_metadata = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Cluster
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Cluster
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data_dns1(self):
""" Get data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
return self._data_dns1
@data_dns1.setter
def data_dns1(self, value):
""" Set data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
self._data_dns1 = value
@property
def data_dns2(self):
""" Get data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
return self._data_dns2
@data_dns2.setter
def data_dns2(self, value):
""" Set data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
self._data_dns2 = value
@property
def data_gateway(self):
""" Get data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
return self._data_gateway
@data_gateway.setter
def data_gateway(self, value):
""" Set data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
self._data_gateway = value
@property
def data_network_portgroup(self):
""" Get data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
return self._data_network_portgroup
@data_network_portgroup.setter
def data_network_portgroup(self, value):
""" Set data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
self._data_network_portgroup = value
@property
def datapath_sync_timeout(self):
""" Get datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
return self._datapath_sync_timeout
@datapath_sync_timeout.setter
def datapath_sync_timeout(self, value):
""" Set datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
self._datapath_sync_timeout = value
@property
def secondary_nuage_controller(self):
""" Get secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
return self._secondary_nuage_controller
@secondary_nuage_controller.setter
def secondary_nuage_controller(self, value):
""" Set secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
self._secondary_nuage_controller = value
@property
def generic_split_activation(self):
""" Get generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
return self._generic_split_activation
@generic_split_activation.setter
def generic_split_activation(self, value):
""" Set generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
self._generic_split_activation = value
@property
def separate_data_network(self):
""" Get separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
return self._separate_data_network
@separate_data_network.setter
def separate_data_network(self, value):
""" Set separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
self._separate_data_network = value
@property
def personality(self):
""" Get personality value.
Notes:
VRS/VRS-G
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
VRS/VRS-G
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Cluster
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Cluster
"""
self._description = value
@property
def metadata_server_ip(self):
""" Get metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
return self._metadata_server_ip
@metadata_server_ip.setter
def metadata_server_ip(self, value):
""" Set metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
self._metadata_server_ip = value
@property
def metadata_server_listen_port(self):
""" Get metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
return self._metadata_server_listen_port
@metadata_server_listen_port.setter
def metadata_server_listen_port(self, value):
""" Set metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
self._metadata_server_listen_port = value
@property
def metadata_server_port(self):
""" Get metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
return self._metadata_server_port
@metadata_server_port.setter
def metadata_server_port(self, value):
""" Set metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
self._metadata_server_port = value
@property
def metadata_service_enabled(self):
""" Get metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
return self._metadata_service_enabled
@metadata_service_enabled.setter
def metadata_service_enabled(self, value):
""" Set metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
self._metadata_service_enabled = value
@property
def network_uplink_interface(self):
""" Get network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
return self._network_uplink_interface
@network_uplink_interface.setter
def network_uplink_interface(self, value):
""" Set network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
self._network_uplink_interface = value
@property
def network_uplink_interface_gateway(self):
""" Get network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
return self._network_uplink_interface_gateway
@network_uplink_interface_gateway.setter
def network_uplink_interface_gateway(self, value):
""" Set network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
self._network_uplink_interface_gateway = value
@property
def network_uplink_interface_ip(self):
""" Get network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
return self._network_uplink_interface_ip
@network_uplink_interface_ip.setter
def network_uplink_interface_ip(self, value):
""" Set network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
self._network_uplink_interface_ip = value
@property
def network_uplink_interface_netmask(self):
""" Get network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
return self._network_uplink_interface_netmask
@network_uplink_interface_netmask.setter
def network_uplink_interface_netmask(self, value):
""" Set network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
self._network_uplink_interface_netmask = value
@property
def nfs_log_server(self):
""" Get nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
return self._nfs_log_server
@nfs_log_server.setter
def nfs_log_server(self, value):
""" Set nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
self._nfs_log_server = value
@property
def nfs_mount_path(self):
""" Get nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
return self._nfs_mount_path
@nfs_mount_path.setter
def nfs_mount_path(self, value):
""" Set nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
self._nfs_mount_path = value
@property
def mgmt_dns1(self):
""" Get mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
return self._mgmt_dns1
@mgmt_dns1.setter
def mgmt_dns1(self, value):
""" Set mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
self._mgmt_dns1 = value
@property
def mgmt_dns2(self):
""" Get mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
return self._mgmt_dns2
@mgmt_dns2.setter
def mgmt_dns2(self, value):
""" Set mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
self._mgmt_dns2 = value
@property
def mgmt_gateway(self):
""" Get mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
return self._mgmt_gateway
@mgmt_gateway.setter
def mgmt_gateway(self, value):
""" Set mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
self._mgmt_gateway = value
@property
def mgmt_network_portgroup(self):
""" Get mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
return self._mgmt_network_portgroup
@mgmt_network_portgroup.setter
def mgmt_network_portgroup(self, value):
""" Set mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
self._mgmt_network_portgroup = value
@property
def dhcp_relay_server(self):
""" Get dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
return self._dhcp_relay_server
@dhcp_relay_server.setter
def dhcp_relay_server(self, value):
""" Set dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
self._dhcp_relay_server = value
@property
def site_id(self):
""" Get site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
return self._site_id
@site_id.setter
def site_id(self, value):
""" Set site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
self._site_id = value
@property
def allow_data_dhcp(self):
""" Get allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
return self._allow_data_dhcp
@allow_data_dhcp.setter
def allow_data_dhcp(self, value):
""" Set allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
self._allow_data_dhcp = value
@property
def allow_mgmt_dhcp(self):
""" Get allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically.
This attribute is named `allowMgmtDHCP` in VSD API.
"""
return self._allow_mgmt_dhcp
@allow_mgmt_dhcp.setter
def allow_mgmt_dhcp(self, value):
""" Set allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically.
This attribute is named `allowMgmtDHCP` in VSD API.
"""
self._allow_mgmt_dhcp = value
@property
def flow_eviction_threshold(self):
""" Get flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
return self._flow_eviction_threshold
@flow_eviction_threshold.setter
def flow_eviction_threshold(self, value):
""" Set flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
self._flow_eviction_threshold = value
@property
def vm_network_portgroup(self):
""" Get vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
return self._vm_network_portgroup
@vm_network_portgroup.setter
def vm_network_portgroup(self, value):
""" Set vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
self._vm_network_portgroup = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def portgroup_metadata(self):
""" Get portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
return self._portgroup_metadata
@portgroup_metadata.setter
def portgroup_metadata(self, value):
""" Set portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
self._portgroup_metadata = value
@property
def nova_client_version(self):
""" Get nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
return self._nova_client_version
@nova_client_version.setter
def nova_client_version(self, value):
""" Set nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
self._nova_client_version = value
@property
def nova_metadata_service_auth_url(self):
""" Get nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
return self._nova_metadata_service_auth_url
@nova_metadata_service_auth_url.setter
def nova_metadata_service_auth_url(self, value):
""" Set nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
self._nova_metadata_service_auth_url = value
@property
def nova_metadata_service_endpoint(self):
""" Get nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
return self._nova_metadata_service_endpoint
@nova_metadata_service_endpoint.setter
def nova_metadata_service_endpoint(self, value):
""" Set nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
self._nova_metadata_service_endpoint = value
@property
def nova_metadata_service_password(self):
""" Get nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
return self._nova_metadata_service_password
@nova_metadata_service_password.setter
def nova_metadata_service_password(self, value):
""" Set nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
self._nova_metadata_service_password = value
@property
def nova_metadata_service_tenant(self):
""" Get nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
return self._nova_metadata_service_tenant
@nova_metadata_service_tenant.setter
def nova_metadata_service_tenant(self, value):
""" Set nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
self._nova_metadata_service_tenant = value
@property
def nova_metadata_service_username(self):
""" Get nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
return self._nova_metadata_service_username
@nova_metadata_service_username.setter
def nova_metadata_service_username(self, value):
""" Set nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
self._nova_metadata_service_username = value
@property
def nova_metadata_shared_secret(self):
""" Get nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
return self._nova_metadata_shared_secret
@nova_metadata_shared_secret.setter
def nova_metadata_shared_secret(self, value):
""" Set nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
self._nova_metadata_shared_secret = value
@property
def nova_region_name(self):
""" Get nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
return self._nova_region_name
@nova_region_name.setter
def nova_region_name(self, value):
""" Set nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
self._nova_region_name = value
@property
def primary_nuage_controller(self):
""" Get primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
return self._primary_nuage_controller
@primary_nuage_controller.setter
def primary_nuage_controller(self, value):
""" Set primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
self._primary_nuage_controller = value
@property
def vrs_password(self):
""" Get vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
return self._vrs_password
@vrs_password.setter
def vrs_password(self, value):
""" Set vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
self._vrs_password = value
@property
def vrs_user_name(self):
""" Get vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
return self._vrs_user_name
@vrs_user_name.setter
def vrs_user_name(self, value):
""" Set vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
self._vrs_user_name = value
@property
def assoc_vcenter_data_center_id(self):
""" Get assoc_vcenter_data_center_id value.
Notes:
The ID of the vcenter to which this host is attached
This attribute is named `assocVCenterDataCenterID` in VSD API.
"""
return self._assoc_vcenter_data_center_id
@assoc_vcenter_data_center_id.setter
def assoc_vcenter_data_center_id(self, value):
""" Set assoc_vcenter_data_center_id value.
Notes:
The ID of the vcenter to which this host is attached
This attribute is named `assocVCenterDataCenterID` in VSD API.
"""
self._assoc_vcenter_data_center_id = value
@property
def static_route(self):
""" Get static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
return self._static_route
@static_route.setter
def static_route(self, value):
""" Set static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
self._static_route = value
@property
def static_route_gateway(self):
""" Get static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
return self._static_route_gateway
@static_route_gateway.setter
def static_route_gateway(self, value):
""" Set static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
self._static_route_gateway = value
@property
def static_route_netmask(self):
""" Get static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
return self._static_route_netmask
@static_route_netmask.setter
def static_route_netmask(self, value):
""" Set static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
self._static_route_netmask = value
@property
def ntp_server1(self):
""" Get ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
return self._ntp_server1
@ntp_server1.setter
def ntp_server1(self, value):
""" Set ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
self._ntp_server1 = value
@property
def ntp_server2(self):
""" Get ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
return self._ntp_server2
@ntp_server2.setter
def ntp_server2(self, value):
""" Set ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
self._ntp_server2 = value
@property
def mtu(self):
""" Get mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
return self._mtu
@mtu.setter
def mtu(self, value):
""" Set mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
self._mtu = value
@property
def multi_vmssupport(self):
""" Get multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
return self._multi_vmssupport
@multi_vmssupport.setter
def multi_vmssupport(self, value):
""" Set multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
self._multi_vmssupport = value
@property
def multicast_receive_interface(self):
""" Get multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
return self._multicast_receive_interface
@multicast_receive_interface.setter
def multicast_receive_interface(self, value):
""" Set multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
self._multicast_receive_interface = value
@property
def multicast_receive_interface_ip(self):
""" Get multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
return self._multicast_receive_interface_ip
@multicast_receive_interface_ip.setter
def multicast_receive_interface_ip(self, value):
""" Set multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
self._multicast_receive_interface_ip = value
@property
def multicast_receive_interface_netmask(self):
""" Get multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
return self._multicast_receive_interface_netmask
@multicast_receive_interface_netmask.setter
def multicast_receive_interface_netmask(self, value):
""" Set multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
self._multicast_receive_interface_netmask = value
@property
def multicast_receive_range(self):
""" Get multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
return self._multicast_receive_range
@multicast_receive_range.setter
def multicast_receive_range(self, value):
""" Set multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
self._multicast_receive_range = value
@property
def multicast_send_interface(self):
""" Get multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
return self._multicast_send_interface
@multicast_send_interface.setter
def multicast_send_interface(self, value):
""" Set multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
self._multicast_send_interface = value
@property
def multicast_send_interface_ip(self):
""" Get multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
return self._multicast_send_interface_ip
@multicast_send_interface_ip.setter
def multicast_send_interface_ip(self, value):
""" Set multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
self._multicast_send_interface_ip = value
@property
def multicast_send_interface_netmask(self):
""" Get multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
return self._multicast_send_interface_netmask
@multicast_send_interface_netmask.setter
def multicast_send_interface_netmask(self, value):
""" Set multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
self._multicast_send_interface_netmask = value
@property
def multicast_source_portgroup(self):
""" Get multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
return self._multicast_source_portgroup
@multicast_source_portgroup.setter
def multicast_source_portgroup(self, value):
""" Set multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
self._multicast_source_portgroup = value
@property
def customized_script_url(self):
""" Get customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
return self._customized_script_url
@customized_script_url.setter
def customized_script_url(self, value):
""" Set customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
self._customized_script_url = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVCenterCluster
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var allow_data_dhcp
Get allow_data_dhcp value.
Notes: Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
var allow_mgmt_dhcp
Get allow_mgmt_dhcp value.
Notes: Whether to get the management IP for the VRS VM from DHCP or statically.
This attribute is named `allowMgmtDHCP` in VSD API.
var arp_reply
Get arp_reply value.
Notes: Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
var assoc_vcenter_data_center_id
Get assoc_vcenter_data_center_id value.
Notes: The ID of the vcenter to which this host is attached
This attribute is named `assocVCenterDataCenterID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var customized_script_url
Get customized_script_url value.
Notes: To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
var data_dns1
Get data_dns1 value.
Notes: Data DNS 1
This attribute is named `dataDNS1` in VSD API.
var data_dns2
Get data_dns2 value.
Notes: Data DNS 2
This attribute is named `dataDNS2` in VSD API.
var data_gateway
Get data_gateway value.
Notes: Data Gateway
This attribute is named `dataGateway` in VSD API.
var data_network_portgroup
Get data_network_portgroup value.
Notes: Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
var datapath_sync_timeout
Get datapath_sync_timeout value.
Notes: Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
var description
Get description value.
Notes: Description of the Cluster
var dhcp_relay_server
Get dhcp_relay_server value.
Notes: To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_eviction_threshold
Get flow_eviction_threshold value.
Notes: Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
var generic_split_activation
Get generic_split_activation value.
Notes: Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_server_ip
Get metadata_server_ip value.
Notes: Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
var metadata_server_listen_port
Get metadata_server_listen_port value.
Notes: Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
var metadata_server_port
Get metadata_server_port value.
Notes: Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
var metadata_service_enabled
Get metadata_service_enabled value.
Notes: Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
var metadatas
var mgmt_dns1
Get mgmt_dns1 value.
Notes: DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
var mgmt_dns2
Get mgmt_dns2 value.
Notes: DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
var mgmt_gateway
Get mgmt_gateway value.
Notes: Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
var mgmt_network_portgroup
Get mgmt_network_portgroup value.
Notes: Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
var mtu
Get mtu value.
Notes: Maximum Transmission Unit for eth2 interface
var multi_vmssupport
Get multi_vmssupport value.
Notes: Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
var multicast_receive_interface
Get multicast_receive_interface value.
Notes: Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
var multicast_receive_interface_ip
Get multicast_receive_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
var multicast_receive_interface_netmask
Get multicast_receive_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
var multicast_receive_range
Get multicast_receive_range value.
Notes: Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
var multicast_send_interface
Get multicast_send_interface value.
Notes: Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
var multicast_send_interface_ip
Get multicast_send_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
var multicast_send_interface_netmask
Get multicast_send_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
var multicast_source_portgroup
Get multicast_source_portgroup value.
Notes: Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
var name
Get name value.
Notes: Name of the Cluster
var network_uplink_interface
Get network_uplink_interface value.
Notes: Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
var network_uplink_interface_gateway
Get network_uplink_interface_gateway value.
Notes: Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
var network_uplink_interface_ip
Get network_uplink_interface_ip value.
Notes: Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
var network_uplink_interface_netmask
Get network_uplink_interface_netmask value.
Notes: Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
var nfs_log_server
Get nfs_log_server value.
Notes: IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
var nfs_mount_path
Get nfs_mount_path value.
Notes: Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
var nova_client_version
Get nova_client_version value.
Notes: Nova client Version
This attribute is named `novaClientVersion` in VSD API.
var nova_metadata_service_auth_url
Get nova_metadata_service_auth_url value.
Notes: Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
var nova_metadata_service_endpoint
Get nova_metadata_service_endpoint value.
Notes: Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
var nova_metadata_service_password
Get nova_metadata_service_password value.
Notes: Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
var nova_metadata_service_tenant
Get nova_metadata_service_tenant value.
Notes: Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
var nova_metadata_service_username
Get nova_metadata_service_username value.
Notes: Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
Get nova_metadata_shared_secret value.
Notes: Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
var nova_region_name
Get nova_region_name value.
Notes: Nova region name
This attribute is named `novaRegionName` in VSD API.
var ntp_server1
Get ntp_server1 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
var ntp_server2
Get ntp_server2 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var personality
Get personality value.
Notes: VRS/VRS-G
var portgroup_metadata
Get portgroup_metadata value.
Notes: Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
var primary_nuage_controller
Get primary_nuage_controller value.
Notes: IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
var secondary_nuage_controller
Get secondary_nuage_controller value.
Notes: IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
var separate_data_network
Get separate_data_network value.
Notes: Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
var site_id
Get site_id value.
Notes: Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
var static_route
Get static_route value.
Notes: static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
var static_route_gateway
Get static_route_gateway value.
Notes: Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
var static_route_netmask
Get static_route_netmask value.
Notes: Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
var v_require_nuage_metadata
Get v_require_nuage_metadata value.
Notes: Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
var vcenter_hypervisors
var vm_network_portgroup
Get vm_network_portgroup value.
Notes: VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
var vrs_address_ranges
var vrs_password
Get vrs_password value.
Notes: VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
var vrs_user_name
Get vrs_user_name value.
Notes: VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VCenterCluster instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vcentercluster = NUVCenterCluster(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterCluster') >>> vcentercluster = NUVCenterCluster(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VCenterCluster instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcentercluster = NUVCenterCluster(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterCluster')
>>> vcentercluster = NUVCenterCluster(data=my_dict)
"""
super(NUVCenterCluster, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_password = None
self._vrs_user_name = None
self._assoc_vcenter_data_center_id = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="assoc_vcenter_data_center_id", remote_name="assocVCenterDataCenterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.vcenter_hypervisors = NUVCenterHypervisorsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVCenterDataCenter
Represents a VCenterDataCenter in the VSD
Notes: VCenter DataCenters.
class NUVCenterDataCenter(NURESTObject):
""" Represents a VCenterDataCenter in the VSD
Notes:
VCenter DataCenters.
"""
__rest_name__ = "vcenterdatacenter"
__resource_name__ = "vcenterdatacenters"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VCenterDataCenter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcenterdatacenter = NUVCenterDataCenter(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterDataCenter')
>>> vcenterdatacenter = NUVCenterDataCenter(data=my_dict)
"""
super(NUVCenterDataCenter, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_password = None
self._vrs_user_name = None
self._associated_vcenter_id = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vcenter_id", remote_name="associatedVCenterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.vcenter_clusters = NUVCenterClustersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def arp_reply(self):
""" Get arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
return self._arp_reply
@arp_reply.setter
def arp_reply(self, value):
""" Set arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
self._arp_reply = value
@property
def v_require_nuage_metadata(self):
""" Get v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
return self._v_require_nuage_metadata
@v_require_nuage_metadata.setter
def v_require_nuage_metadata(self, value):
""" Set v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
self._v_require_nuage_metadata = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Datacenter
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Datacenter
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data_dns1(self):
""" Get data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
return self._data_dns1
@data_dns1.setter
def data_dns1(self, value):
""" Set data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
self._data_dns1 = value
@property
def data_dns2(self):
""" Get data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
return self._data_dns2
@data_dns2.setter
def data_dns2(self, value):
""" Set data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
self._data_dns2 = value
@property
def data_gateway(self):
""" Get data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
return self._data_gateway
@data_gateway.setter
def data_gateway(self, value):
""" Set data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
self._data_gateway = value
@property
def data_network_portgroup(self):
""" Get data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
return self._data_network_portgroup
@data_network_portgroup.setter
def data_network_portgroup(self, value):
""" Set data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
self._data_network_portgroup = value
@property
def datapath_sync_timeout(self):
""" Get datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
return self._datapath_sync_timeout
@datapath_sync_timeout.setter
def datapath_sync_timeout(self, value):
""" Set datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
self._datapath_sync_timeout = value
@property
def secondary_nuage_controller(self):
""" Get secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
return self._secondary_nuage_controller
@secondary_nuage_controller.setter
def secondary_nuage_controller(self, value):
""" Set secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
self._secondary_nuage_controller = value
@property
def generic_split_activation(self):
""" Get generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
return self._generic_split_activation
@generic_split_activation.setter
def generic_split_activation(self, value):
""" Set generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
self._generic_split_activation = value
@property
def separate_data_network(self):
""" Get separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
return self._separate_data_network
@separate_data_network.setter
def separate_data_network(self, value):
""" Set separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
self._separate_data_network = value
@property
def personality(self):
""" Get personality value.
Notes:
VRS/VRS-G
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
VRS/VRS-G
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Datacenter
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Datacenter
"""
self._description = value
@property
def metadata_server_ip(self):
""" Get metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
return self._metadata_server_ip
@metadata_server_ip.setter
def metadata_server_ip(self, value):
""" Set metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
self._metadata_server_ip = value
@property
def metadata_server_listen_port(self):
""" Get metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
return self._metadata_server_listen_port
@metadata_server_listen_port.setter
def metadata_server_listen_port(self, value):
""" Set metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
self._metadata_server_listen_port = value
@property
def metadata_server_port(self):
""" Get metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
return self._metadata_server_port
@metadata_server_port.setter
def metadata_server_port(self, value):
""" Set metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
self._metadata_server_port = value
@property
def metadata_service_enabled(self):
""" Get metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
return self._metadata_service_enabled
@metadata_service_enabled.setter
def metadata_service_enabled(self, value):
""" Set metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
self._metadata_service_enabled = value
@property
def network_uplink_interface(self):
""" Get network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
return self._network_uplink_interface
@network_uplink_interface.setter
def network_uplink_interface(self, value):
""" Set network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
self._network_uplink_interface = value
@property
def network_uplink_interface_gateway(self):
""" Get network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
return self._network_uplink_interface_gateway
@network_uplink_interface_gateway.setter
def network_uplink_interface_gateway(self, value):
""" Set network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
self._network_uplink_interface_gateway = value
@property
def network_uplink_interface_ip(self):
""" Get network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
return self._network_uplink_interface_ip
@network_uplink_interface_ip.setter
def network_uplink_interface_ip(self, value):
""" Set network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
self._network_uplink_interface_ip = value
@property
def network_uplink_interface_netmask(self):
""" Get network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
return self._network_uplink_interface_netmask
@network_uplink_interface_netmask.setter
def network_uplink_interface_netmask(self, value):
""" Set network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
self._network_uplink_interface_netmask = value
@property
def nfs_log_server(self):
""" Get nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
return self._nfs_log_server
@nfs_log_server.setter
def nfs_log_server(self, value):
""" Set nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
self._nfs_log_server = value
@property
def nfs_mount_path(self):
""" Get nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
return self._nfs_mount_path
@nfs_mount_path.setter
def nfs_mount_path(self, value):
""" Set nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
self._nfs_mount_path = value
@property
def mgmt_dns1(self):
""" Get mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
return self._mgmt_dns1
@mgmt_dns1.setter
def mgmt_dns1(self, value):
""" Set mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
self._mgmt_dns1 = value
@property
def mgmt_dns2(self):
""" Get mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
return self._mgmt_dns2
@mgmt_dns2.setter
def mgmt_dns2(self, value):
""" Set mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
self._mgmt_dns2 = value
@property
def mgmt_gateway(self):
""" Get mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
return self._mgmt_gateway
@mgmt_gateway.setter
def mgmt_gateway(self, value):
""" Set mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
self._mgmt_gateway = value
@property
def mgmt_network_portgroup(self):
""" Get mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
return self._mgmt_network_portgroup
@mgmt_network_portgroup.setter
def mgmt_network_portgroup(self, value):
""" Set mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
self._mgmt_network_portgroup = value
@property
def dhcp_relay_server(self):
""" Get dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
return self._dhcp_relay_server
@dhcp_relay_server.setter
def dhcp_relay_server(self, value):
""" Set dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
self._dhcp_relay_server = value
@property
def site_id(self):
""" Get site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
return self._site_id
@site_id.setter
def site_id(self, value):
""" Set site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
self._site_id = value
@property
def allow_data_dhcp(self):
""" Get allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
return self._allow_data_dhcp
@allow_data_dhcp.setter
def allow_data_dhcp(self, value):
""" Set allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
self._allow_data_dhcp = value
@property
def allow_mgmt_dhcp(self):
""" Get allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
return self._allow_mgmt_dhcp
@allow_mgmt_dhcp.setter
def allow_mgmt_dhcp(self, value):
""" Set allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
self._allow_mgmt_dhcp = value
@property
def flow_eviction_threshold(self):
""" Get flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
return self._flow_eviction_threshold
@flow_eviction_threshold.setter
def flow_eviction_threshold(self, value):
""" Set flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
self._flow_eviction_threshold = value
@property
def vm_network_portgroup(self):
""" Get vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
return self._vm_network_portgroup
@vm_network_portgroup.setter
def vm_network_portgroup(self, value):
""" Set vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
self._vm_network_portgroup = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def portgroup_metadata(self):
""" Get portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
return self._portgroup_metadata
@portgroup_metadata.setter
def portgroup_metadata(self, value):
""" Set portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
self._portgroup_metadata = value
@property
def nova_client_version(self):
""" Get nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
return self._nova_client_version
@nova_client_version.setter
def nova_client_version(self, value):
""" Set nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
self._nova_client_version = value
@property
def nova_metadata_service_auth_url(self):
""" Get nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
return self._nova_metadata_service_auth_url
@nova_metadata_service_auth_url.setter
def nova_metadata_service_auth_url(self, value):
""" Set nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
self._nova_metadata_service_auth_url = value
@property
def nova_metadata_service_endpoint(self):
""" Get nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
return self._nova_metadata_service_endpoint
@nova_metadata_service_endpoint.setter
def nova_metadata_service_endpoint(self, value):
""" Set nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
self._nova_metadata_service_endpoint = value
@property
def nova_metadata_service_password(self):
""" Get nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
return self._nova_metadata_service_password
@nova_metadata_service_password.setter
def nova_metadata_service_password(self, value):
""" Set nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
self._nova_metadata_service_password = value
@property
def nova_metadata_service_tenant(self):
""" Get nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
return self._nova_metadata_service_tenant
@nova_metadata_service_tenant.setter
def nova_metadata_service_tenant(self, value):
""" Set nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
self._nova_metadata_service_tenant = value
@property
def nova_metadata_service_username(self):
""" Get nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
return self._nova_metadata_service_username
@nova_metadata_service_username.setter
def nova_metadata_service_username(self, value):
""" Set nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
self._nova_metadata_service_username = value
@property
def nova_metadata_shared_secret(self):
""" Get nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
return self._nova_metadata_shared_secret
@nova_metadata_shared_secret.setter
def nova_metadata_shared_secret(self, value):
""" Set nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
self._nova_metadata_shared_secret = value
@property
def nova_region_name(self):
""" Get nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
return self._nova_region_name
@nova_region_name.setter
def nova_region_name(self, value):
""" Set nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
self._nova_region_name = value
@property
def primary_nuage_controller(self):
""" Get primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
return self._primary_nuage_controller
@primary_nuage_controller.setter
def primary_nuage_controller(self, value):
""" Set primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
self._primary_nuage_controller = value
@property
def vrs_password(self):
""" Get vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
return self._vrs_password
@vrs_password.setter
def vrs_password(self, value):
""" Set vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
self._vrs_password = value
@property
def vrs_user_name(self):
""" Get vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
return self._vrs_user_name
@vrs_user_name.setter
def vrs_user_name(self, value):
""" Set vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
self._vrs_user_name = value
@property
def associated_vcenter_id(self):
""" Get associated_vcenter_id value.
Notes:
The ID of the vcenter to which this host is attached
This attribute is named `associatedVCenterID` in VSD API.
"""
return self._associated_vcenter_id
@associated_vcenter_id.setter
def associated_vcenter_id(self, value):
""" Set associated_vcenter_id value.
Notes:
The ID of the vcenter to which this host is attached
This attribute is named `associatedVCenterID` in VSD API.
"""
self._associated_vcenter_id = value
@property
def static_route(self):
""" Get static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
return self._static_route
@static_route.setter
def static_route(self, value):
""" Set static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
self._static_route = value
@property
def static_route_gateway(self):
""" Get static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
return self._static_route_gateway
@static_route_gateway.setter
def static_route_gateway(self, value):
""" Set static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
self._static_route_gateway = value
@property
def static_route_netmask(self):
""" Get static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
return self._static_route_netmask
@static_route_netmask.setter
def static_route_netmask(self, value):
""" Set static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
self._static_route_netmask = value
@property
def ntp_server1(self):
""" Get ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
return self._ntp_server1
@ntp_server1.setter
def ntp_server1(self, value):
""" Set ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
self._ntp_server1 = value
@property
def ntp_server2(self):
""" Get ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
return self._ntp_server2
@ntp_server2.setter
def ntp_server2(self, value):
""" Set ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
self._ntp_server2 = value
@property
def mtu(self):
""" Get mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
return self._mtu
@mtu.setter
def mtu(self, value):
""" Set mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
self._mtu = value
@property
def multi_vmssupport(self):
""" Get multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
return self._multi_vmssupport
@multi_vmssupport.setter
def multi_vmssupport(self, value):
""" Set multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
self._multi_vmssupport = value
@property
def multicast_receive_interface(self):
""" Get multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
return self._multicast_receive_interface
@multicast_receive_interface.setter
def multicast_receive_interface(self, value):
""" Set multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
self._multicast_receive_interface = value
@property
def multicast_receive_interface_ip(self):
""" Get multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
return self._multicast_receive_interface_ip
@multicast_receive_interface_ip.setter
def multicast_receive_interface_ip(self, value):
""" Set multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
self._multicast_receive_interface_ip = value
@property
def multicast_receive_interface_netmask(self):
""" Get multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
return self._multicast_receive_interface_netmask
@multicast_receive_interface_netmask.setter
def multicast_receive_interface_netmask(self, value):
""" Set multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
self._multicast_receive_interface_netmask = value
@property
def multicast_receive_range(self):
""" Get multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
return self._multicast_receive_range
@multicast_receive_range.setter
def multicast_receive_range(self, value):
""" Set multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
self._multicast_receive_range = value
@property
def multicast_send_interface(self):
""" Get multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
return self._multicast_send_interface
@multicast_send_interface.setter
def multicast_send_interface(self, value):
""" Set multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
self._multicast_send_interface = value
@property
def multicast_send_interface_ip(self):
""" Get multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
return self._multicast_send_interface_ip
@multicast_send_interface_ip.setter
def multicast_send_interface_ip(self, value):
""" Set multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
self._multicast_send_interface_ip = value
@property
def multicast_send_interface_netmask(self):
""" Get multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
return self._multicast_send_interface_netmask
@multicast_send_interface_netmask.setter
def multicast_send_interface_netmask(self, value):
""" Set multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
self._multicast_send_interface_netmask = value
@property
def multicast_source_portgroup(self):
""" Get multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
return self._multicast_source_portgroup
@multicast_source_portgroup.setter
def multicast_source_portgroup(self, value):
""" Set multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
self._multicast_source_portgroup = value
@property
def customized_script_url(self):
""" Get customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
return self._customized_script_url
@customized_script_url.setter
def customized_script_url(self, value):
""" Set customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
self._customized_script_url = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVCenterDataCenter
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var allow_data_dhcp
Get allow_data_dhcp value.
Notes: Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
var allow_mgmt_dhcp
Get allow_mgmt_dhcp value.
Notes: Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
var arp_reply
Get arp_reply value.
Notes: Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
var associated_vcenter_id
Get associated_vcenter_id value.
Notes: The ID of the vcenter to which this host is attached
This attribute is named `associatedVCenterID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var customized_script_url
Get customized_script_url value.
Notes: To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
var data_dns1
Get data_dns1 value.
Notes: Data DNS 1
This attribute is named `dataDNS1` in VSD API.
var data_dns2
Get data_dns2 value.
Notes: Data DNS 2
This attribute is named `dataDNS2` in VSD API.
var data_gateway
Get data_gateway value.
Notes: Data Gateway
This attribute is named `dataGateway` in VSD API.
var data_network_portgroup
Get data_network_portgroup value.
Notes: Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
var datapath_sync_timeout
Get datapath_sync_timeout value.
Notes: Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
var description
Get description value.
Notes: Description of the Datacenter
var dhcp_relay_server
Get dhcp_relay_server value.
Notes: To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_eviction_threshold
Get flow_eviction_threshold value.
Notes: Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
var generic_split_activation
Get generic_split_activation value.
Notes: Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_server_ip
Get metadata_server_ip value.
Notes: Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
var metadata_server_listen_port
Get metadata_server_listen_port value.
Notes: Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
var metadata_server_port
Get metadata_server_port value.
Notes: Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
var metadata_service_enabled
Get metadata_service_enabled value.
Notes: Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
var metadatas
var mgmt_dns1
Get mgmt_dns1 value.
Notes: DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
var mgmt_dns2
Get mgmt_dns2 value.
Notes: DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
var mgmt_gateway
Get mgmt_gateway value.
Notes: Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
var mgmt_network_portgroup
Get mgmt_network_portgroup value.
Notes: Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
var mtu
Get mtu value.
Notes: Maximum Transmission Unit for eth2 interface
var multi_vmssupport
Get multi_vmssupport value.
Notes: Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
var multicast_receive_interface
Get multicast_receive_interface value.
Notes: Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
var multicast_receive_interface_ip
Get multicast_receive_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
var multicast_receive_interface_netmask
Get multicast_receive_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
var multicast_receive_range
Get multicast_receive_range value.
Notes: Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
var multicast_send_interface
Get multicast_send_interface value.
Notes: Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
var multicast_send_interface_ip
Get multicast_send_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
var multicast_send_interface_netmask
Get multicast_send_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
var multicast_source_portgroup
Get multicast_source_portgroup value.
Notes: Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
var name
Get name value.
Notes: Name of the Datacenter
var network_uplink_interface
Get network_uplink_interface value.
Notes: Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
var network_uplink_interface_gateway
Get network_uplink_interface_gateway value.
Notes: Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
var network_uplink_interface_ip
Get network_uplink_interface_ip value.
Notes: Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
var network_uplink_interface_netmask
Get network_uplink_interface_netmask value.
Notes: Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
var nfs_log_server
Get nfs_log_server value.
Notes: IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
var nfs_mount_path
Get nfs_mount_path value.
Notes: Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
var nova_client_version
Get nova_client_version value.
Notes: Nova client Version
This attribute is named `novaClientVersion` in VSD API.
var nova_metadata_service_auth_url
Get nova_metadata_service_auth_url value.
Notes: Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
var nova_metadata_service_endpoint
Get nova_metadata_service_endpoint value.
Notes: Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
var nova_metadata_service_password
Get nova_metadata_service_password value.
Notes: Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
var nova_metadata_service_tenant
Get nova_metadata_service_tenant value.
Notes: Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
var nova_metadata_service_username
Get nova_metadata_service_username value.
Notes: Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
Get nova_metadata_shared_secret value.
Notes: Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
var nova_region_name
Get nova_region_name value.
Notes: Nova region name
This attribute is named `novaRegionName` in VSD API.
var ntp_server1
Get ntp_server1 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
var ntp_server2
Get ntp_server2 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var personality
Get personality value.
Notes: VRS/VRS-G
var portgroup_metadata
Get portgroup_metadata value.
Notes: Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
var primary_nuage_controller
Get primary_nuage_controller value.
Notes: IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
var secondary_nuage_controller
Get secondary_nuage_controller value.
Notes: IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
var separate_data_network
Get separate_data_network value.
Notes: Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
var site_id
Get site_id value.
Notes: Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
var static_route
Get static_route value.
Notes: static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
var static_route_gateway
Get static_route_gateway value.
Notes: Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
var static_route_netmask
Get static_route_netmask value.
Notes: Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
var v_require_nuage_metadata
Get v_require_nuage_metadata value.
Notes: Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
var vcenter_clusters
var vm_network_portgroup
Get vm_network_portgroup value.
Notes: VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
var vrs_address_ranges
var vrs_password
Get vrs_password value.
Notes: VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
var vrs_user_name
Get vrs_user_name value.
Notes: VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VCenterDataCenter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vcenterdatacenter = NUVCenterDataCenter(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterDataCenter') >>> vcenterdatacenter = NUVCenterDataCenter(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VCenterDataCenter instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcenterdatacenter = NUVCenterDataCenter(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterDataCenter')
>>> vcenterdatacenter = NUVCenterDataCenter(data=my_dict)
"""
super(NUVCenterDataCenter, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_password = None
self._vrs_user_name = None
self._associated_vcenter_id = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vcenter_id", remote_name="associatedVCenterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.vcenter_clusters = NUVCenterClustersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVCenterEAMConfig
Represents a VCenterEAMConfig in the VSD
Notes: The EAM solution configuration.
class NUVCenterEAMConfig(NURESTObject):
""" Represents a VCenterEAMConfig in the VSD
Notes:
The EAM solution configuration.
"""
__rest_name__ = "eamconfig"
__resource_name__ = "eamconfigs"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VCenterEAMConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcentereamconfig = NUVCenterEAMConfig(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterEAMConfig')
>>> vcentereamconfig = NUVCenterEAMConfig(data=my_dict)
"""
super(NUVCenterEAMConfig, self).__init__()
# Read/Write Attributes
self._eam_server_ip = None
self._eam_server_port_number = None
self._eam_server_port_type = None
self._last_updated_by = None
self._vib_url = None
self._entity_scope = None
self._ovf_url = None
self._extension_key = None
self._external_id = None
self.expose_attribute(local_name="eam_server_ip", remote_name="eamServerIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="eam_server_port_number", remote_name="eamServerPortNumber", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="eam_server_port_type", remote_name="eamServerPortType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vib_url", remote_name="vibURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="ovf_url", remote_name="ovfURL", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="extension_key", remote_name="extensionKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def eam_server_ip(self):
""" Get eam_server_ip value.
Notes:
The EAM server IP
This attribute is named `eamServerIP` in VSD API.
"""
return self._eam_server_ip
@eam_server_ip.setter
def eam_server_ip(self, value):
""" Set eam_server_ip value.
Notes:
The EAM server IP
This attribute is named `eamServerIP` in VSD API.
"""
self._eam_server_ip = value
@property
def eam_server_port_number(self):
""" Get eam_server_port_number value.
Notes:
The EAM server port number
This attribute is named `eamServerPortNumber` in VSD API.
"""
return self._eam_server_port_number
@eam_server_port_number.setter
def eam_server_port_number(self, value):
""" Set eam_server_port_number value.
Notes:
The EAM server port number
This attribute is named `eamServerPortNumber` in VSD API.
"""
self._eam_server_port_number = value
@property
def eam_server_port_type(self):
""" Get eam_server_port_type value.
Notes:
The EAM server port Type
This attribute is named `eamServerPortType` in VSD API.
"""
return self._eam_server_port_type
@eam_server_port_type.setter
def eam_server_port_type(self, value):
""" Set eam_server_port_type value.
Notes:
The EAM server port Type
This attribute is named `eamServerPortType` in VSD API.
"""
self._eam_server_port_type = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def vib_url(self):
""" Get vib_url value.
Notes:
The url for the optional vib
This attribute is named `vibURL` in VSD API.
"""
return self._vib_url
@vib_url.setter
def vib_url(self, value):
""" Set vib_url value.
Notes:
The url for the optional vib
This attribute is named `vibURL` in VSD API.
"""
self._vib_url = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def ovf_url(self):
""" Get ovf_url value.
Notes:
The url for the ovf
This attribute is named `ovfURL` in VSD API.
"""
return self._ovf_url
@ovf_url.setter
def ovf_url(self, value):
""" Set ovf_url value.
Notes:
The url for the ovf
This attribute is named `ovfURL` in VSD API.
"""
self._ovf_url = value
@property
def extension_key(self):
""" Get extension_key value.
Notes:
Key of the extension that the solution registers
This attribute is named `extensionKey` in VSD API.
"""
return self._extension_key
@extension_key.setter
def extension_key(self, value):
""" Set extension_key value.
Notes:
Key of the extension that the solution registers
This attribute is named `extensionKey` in VSD API.
"""
self._extension_key = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVCenterEAMConfig
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var eam_server_ip
Get eam_server_ip value.
Notes: The EAM server IP
This attribute is named `eamServerIP` in VSD API.
var eam_server_port_number
Get eam_server_port_number value.
Notes: The EAM server port number
This attribute is named `eamServerPortNumber` in VSD API.
var eam_server_port_type
Get eam_server_port_type value.
Notes: The EAM server port Type
This attribute is named `eamServerPortType` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var extension_key
Get extension_key value.
Notes: Key of the extension that the solution registers
This attribute is named `extensionKey` in VSD API.
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var ovf_url
Get ovf_url value.
Notes: The url for the ovf
This attribute is named `ovfURL` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var vib_url
Get vib_url value.
Notes: The url for the optional vib
This attribute is named `vibURL` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VCenterEAMConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vcentereamconfig = NUVCenterEAMConfig(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterEAMConfig') >>> vcentereamconfig = NUVCenterEAMConfig(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VCenterEAMConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcentereamconfig = NUVCenterEAMConfig(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterEAMConfig')
>>> vcentereamconfig = NUVCenterEAMConfig(data=my_dict)
"""
super(NUVCenterEAMConfig, self).__init__()
# Read/Write Attributes
self._eam_server_ip = None
self._eam_server_port_number = None
self._eam_server_port_type = None
self._last_updated_by = None
self._vib_url = None
self._entity_scope = None
self._ovf_url = None
self._extension_key = None
self._external_id = None
self.expose_attribute(local_name="eam_server_ip", remote_name="eamServerIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="eam_server_port_number", remote_name="eamServerPortNumber", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="eam_server_port_type", remote_name="eamServerPortType", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vib_url", remote_name="vibURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="ovf_url", remote_name="ovfURL", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="extension_key", remote_name="extensionKey", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVCenterHypervisor
Represents a VCenterHypervisor in the VSD
Notes: Host or Hypervisors.
class NUVCenterHypervisor(NURESTObject):
""" Represents a VCenterHypervisor in the VSD
Notes:
Host or Hypervisors.
"""
__rest_name__ = "vcenterhypervisor"
__resource_name__ = "vcenterhypervisors"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VCenterHypervisor instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcenterhypervisor = NUVCenterHypervisor(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterHypervisor')
>>> vcenterhypervisor = NUVCenterHypervisor(data=my_dict)
"""
super(NUVCenterHypervisor, self).__init__()
# Read/Write Attributes
self._vcenter_ip = None
self._vcenter_password = None
self._vcenter_user = None
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_ip_address = None
self._data_netmask = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_ip_address = None
self._mgmt_netmask = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._toolbox_deployment_mode = None
self._toolbox_group = None
self._toolbox_ip = None
self._toolbox_password = None
self._toolbox_user_name = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_id = None
self._vrs_password = None
self._vrs_user_name = None
self._associated_cluster_id = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self._hypervisor_ip = None
self._hypervisor_password = None
self._hypervisor_user = None
self.expose_attribute(local_name="vcenter_ip", remote_name="vCenterIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vcenter_password", remote_name="vCenterPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vcenter_user", remote_name="vCenterUser", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_ip_address", remote_name="dataIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_netmask", remote_name="dataNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_ip_address", remote_name="mgmtIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_netmask", remote_name="mgmtNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="toolbox_deployment_mode", remote_name="toolboxDeploymentMode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_group", remote_name="toolboxGroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_ip", remote_name="toolboxIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_password", remote_name="toolboxPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_user_name", remote_name="toolboxUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_id", remote_name="vrsId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_cluster_id", remote_name="associatedClusterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="hypervisor_ip", remote_name="hypervisorIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="hypervisor_password", remote_name="hypervisorPassword", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="hypervisor_user", remote_name="hypervisorUser", attribute_type=str, is_required=True, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vcenter_ip(self):
""" Get vcenter_ip value.
Notes:
IP Address of the VCenter.
This attribute is named `vCenterIP` in VSD API.
"""
return self._vcenter_ip
@vcenter_ip.setter
def vcenter_ip(self, value):
""" Set vcenter_ip value.
Notes:
IP Address of the VCenter.
This attribute is named `vCenterIP` in VSD API.
"""
self._vcenter_ip = value
@property
def vcenter_password(self):
""" Get vcenter_password value.
Notes:
Password for VCenter.
This attribute is named `vCenterPassword` in VSD API.
"""
return self._vcenter_password
@vcenter_password.setter
def vcenter_password(self, value):
""" Set vcenter_password value.
Notes:
Password for VCenter.
This attribute is named `vCenterPassword` in VSD API.
"""
self._vcenter_password = value
@property
def vcenter_user(self):
""" Get vcenter_user value.
Notes:
Username for VCenter.
This attribute is named `vCenterUser` in VSD API.
"""
return self._vcenter_user
@vcenter_user.setter
def vcenter_user(self, value):
""" Set vcenter_user value.
Notes:
Username for VCenter.
This attribute is named `vCenterUser` in VSD API.
"""
self._vcenter_user = value
@property
def arp_reply(self):
""" Get arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
return self._arp_reply
@arp_reply.setter
def arp_reply(self, value):
""" Set arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
self._arp_reply = value
@property
def v_require_nuage_metadata(self):
""" Get v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
return self._v_require_nuage_metadata
@v_require_nuage_metadata.setter
def v_require_nuage_metadata(self, value):
""" Set v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
self._v_require_nuage_metadata = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Hypervisor
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Hypervisor
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data_dns1(self):
""" Get data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
return self._data_dns1
@data_dns1.setter
def data_dns1(self, value):
""" Set data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
self._data_dns1 = value
@property
def data_dns2(self):
""" Get data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
return self._data_dns2
@data_dns2.setter
def data_dns2(self, value):
""" Set data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
self._data_dns2 = value
@property
def data_gateway(self):
""" Get data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
return self._data_gateway
@data_gateway.setter
def data_gateway(self, value):
""" Set data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
self._data_gateway = value
@property
def data_ip_address(self):
""" Get data_ip_address value.
Notes:
Data IP Address
This attribute is named `dataIPAddress` in VSD API.
"""
return self._data_ip_address
@data_ip_address.setter
def data_ip_address(self, value):
""" Set data_ip_address value.
Notes:
Data IP Address
This attribute is named `dataIPAddress` in VSD API.
"""
self._data_ip_address = value
@property
def data_netmask(self):
""" Get data_netmask value.
Notes:
Data NetMask
This attribute is named `dataNetmask` in VSD API.
"""
return self._data_netmask
@data_netmask.setter
def data_netmask(self, value):
""" Set data_netmask value.
Notes:
Data NetMask
This attribute is named `dataNetmask` in VSD API.
"""
self._data_netmask = value
@property
def data_network_portgroup(self):
""" Get data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
return self._data_network_portgroup
@data_network_portgroup.setter
def data_network_portgroup(self, value):
""" Set data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
self._data_network_portgroup = value
@property
def datapath_sync_timeout(self):
""" Get datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
return self._datapath_sync_timeout
@datapath_sync_timeout.setter
def datapath_sync_timeout(self, value):
""" Set datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
self._datapath_sync_timeout = value
@property
def secondary_nuage_controller(self):
""" Get secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
return self._secondary_nuage_controller
@secondary_nuage_controller.setter
def secondary_nuage_controller(self, value):
""" Set secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
self._secondary_nuage_controller = value
@property
def generic_split_activation(self):
""" Get generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
return self._generic_split_activation
@generic_split_activation.setter
def generic_split_activation(self, value):
""" Set generic_split_activation value.
Notes:
Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
self._generic_split_activation = value
@property
def separate_data_network(self):
""" Get separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
return self._separate_data_network
@separate_data_network.setter
def separate_data_network(self, value):
""" Set separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
self._separate_data_network = value
@property
def personality(self):
""" Get personality value.
Notes:
VRS/VRS-G
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
VRS/VRS-G
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
Description of the Hypervisor
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the Hypervisor
"""
self._description = value
@property
def metadata_server_ip(self):
""" Get metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
return self._metadata_server_ip
@metadata_server_ip.setter
def metadata_server_ip(self, value):
""" Set metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
self._metadata_server_ip = value
@property
def metadata_server_listen_port(self):
""" Get metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
return self._metadata_server_listen_port
@metadata_server_listen_port.setter
def metadata_server_listen_port(self, value):
""" Set metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
self._metadata_server_listen_port = value
@property
def metadata_server_port(self):
""" Get metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
return self._metadata_server_port
@metadata_server_port.setter
def metadata_server_port(self, value):
""" Set metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
self._metadata_server_port = value
@property
def metadata_service_enabled(self):
""" Get metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
return self._metadata_service_enabled
@metadata_service_enabled.setter
def metadata_service_enabled(self, value):
""" Set metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
self._metadata_service_enabled = value
@property
def network_uplink_interface(self):
""" Get network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
return self._network_uplink_interface
@network_uplink_interface.setter
def network_uplink_interface(self, value):
""" Set network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
self._network_uplink_interface = value
@property
def network_uplink_interface_gateway(self):
""" Get network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
return self._network_uplink_interface_gateway
@network_uplink_interface_gateway.setter
def network_uplink_interface_gateway(self, value):
""" Set network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
self._network_uplink_interface_gateway = value
@property
def network_uplink_interface_ip(self):
""" Get network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
return self._network_uplink_interface_ip
@network_uplink_interface_ip.setter
def network_uplink_interface_ip(self, value):
""" Set network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
self._network_uplink_interface_ip = value
@property
def network_uplink_interface_netmask(self):
""" Get network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
return self._network_uplink_interface_netmask
@network_uplink_interface_netmask.setter
def network_uplink_interface_netmask(self, value):
""" Set network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
self._network_uplink_interface_netmask = value
@property
def nfs_log_server(self):
""" Get nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
return self._nfs_log_server
@nfs_log_server.setter
def nfs_log_server(self, value):
""" Set nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
self._nfs_log_server = value
@property
def nfs_mount_path(self):
""" Get nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
return self._nfs_mount_path
@nfs_mount_path.setter
def nfs_mount_path(self, value):
""" Set nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
self._nfs_mount_path = value
@property
def mgmt_dns1(self):
""" Get mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
return self._mgmt_dns1
@mgmt_dns1.setter
def mgmt_dns1(self, value):
""" Set mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
self._mgmt_dns1 = value
@property
def mgmt_dns2(self):
""" Get mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
return self._mgmt_dns2
@mgmt_dns2.setter
def mgmt_dns2(self, value):
""" Set mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
self._mgmt_dns2 = value
@property
def mgmt_gateway(self):
""" Get mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
return self._mgmt_gateway
@mgmt_gateway.setter
def mgmt_gateway(self, value):
""" Set mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
self._mgmt_gateway = value
@property
def mgmt_ip_address(self):
""" Get mgmt_ip_address value.
Notes:
The Mangement IP address for VRS VM if needed to be given statically
This attribute is named `mgmtIPAddress` in VSD API.
"""
return self._mgmt_ip_address
@mgmt_ip_address.setter
def mgmt_ip_address(self, value):
""" Set mgmt_ip_address value.
Notes:
The Mangement IP address for VRS VM if needed to be given statically
This attribute is named `mgmtIPAddress` in VSD API.
"""
self._mgmt_ip_address = value
@property
def mgmt_netmask(self):
""" Get mgmt_netmask value.
Notes:
Netmask of the IP address above
This attribute is named `mgmtNetmask` in VSD API.
"""
return self._mgmt_netmask
@mgmt_netmask.setter
def mgmt_netmask(self, value):
""" Set mgmt_netmask value.
Notes:
Netmask of the IP address above
This attribute is named `mgmtNetmask` in VSD API.
"""
self._mgmt_netmask = value
@property
def mgmt_network_portgroup(self):
""" Get mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
return self._mgmt_network_portgroup
@mgmt_network_portgroup.setter
def mgmt_network_portgroup(self, value):
""" Set mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
self._mgmt_network_portgroup = value
@property
def dhcp_relay_server(self):
""" Get dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
return self._dhcp_relay_server
@dhcp_relay_server.setter
def dhcp_relay_server(self, value):
""" Set dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
self._dhcp_relay_server = value
@property
def site_id(self):
""" Get site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
return self._site_id
@site_id.setter
def site_id(self, value):
""" Set site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
self._site_id = value
@property
def allow_data_dhcp(self):
""" Get allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
return self._allow_data_dhcp
@allow_data_dhcp.setter
def allow_data_dhcp(self, value):
""" Set allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
self._allow_data_dhcp = value
@property
def allow_mgmt_dhcp(self):
""" Get allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
return self._allow_mgmt_dhcp
@allow_mgmt_dhcp.setter
def allow_mgmt_dhcp(self, value):
""" Set allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
self._allow_mgmt_dhcp = value
@property
def flow_eviction_threshold(self):
""" Get flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
return self._flow_eviction_threshold
@flow_eviction_threshold.setter
def flow_eviction_threshold(self, value):
""" Set flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
self._flow_eviction_threshold = value
@property
def vm_network_portgroup(self):
""" Get vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
return self._vm_network_portgroup
@vm_network_portgroup.setter
def vm_network_portgroup(self, value):
""" Set vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
self._vm_network_portgroup = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def toolbox_deployment_mode(self):
""" Get toolbox_deployment_mode value.
Notes:
Flag to specify if VRS is deployed using tool box.
This attribute is named `toolboxDeploymentMode` in VSD API.
"""
return self._toolbox_deployment_mode
@toolbox_deployment_mode.setter
def toolbox_deployment_mode(self, value):
""" Set toolbox_deployment_mode value.
Notes:
Flag to specify if VRS is deployed using tool box.
This attribute is named `toolboxDeploymentMode` in VSD API.
"""
self._toolbox_deployment_mode = value
@property
def toolbox_group(self):
""" Get toolbox_group value.
Notes:
Deployment Toolbox Group.
This attribute is named `toolboxGroup` in VSD API.
"""
return self._toolbox_group
@toolbox_group.setter
def toolbox_group(self, value):
""" Set toolbox_group value.
Notes:
Deployment Toolbox Group.
This attribute is named `toolboxGroup` in VSD API.
"""
self._toolbox_group = value
@property
def toolbox_ip(self):
""" Get toolbox_ip value.
Notes:
Deployment Toolbox IP.
This attribute is named `toolboxIP` in VSD API.
"""
return self._toolbox_ip
@toolbox_ip.setter
def toolbox_ip(self, value):
""" Set toolbox_ip value.
Notes:
Deployment Toolbox IP.
This attribute is named `toolboxIP` in VSD API.
"""
self._toolbox_ip = value
@property
def toolbox_password(self):
""" Get toolbox_password value.
Notes:
Deployment Toolbox password.
This attribute is named `toolboxPassword` in VSD API.
"""
return self._toolbox_password
@toolbox_password.setter
def toolbox_password(self, value):
""" Set toolbox_password value.
Notes:
Deployment Toolbox password.
This attribute is named `toolboxPassword` in VSD API.
"""
self._toolbox_password = value
@property
def toolbox_user_name(self):
""" Get toolbox_user_name value.
Notes:
Deployment Toolbox username.
This attribute is named `toolboxUserName` in VSD API.
"""
return self._toolbox_user_name
@toolbox_user_name.setter
def toolbox_user_name(self, value):
""" Set toolbox_user_name value.
Notes:
Deployment Toolbox username.
This attribute is named `toolboxUserName` in VSD API.
"""
self._toolbox_user_name = value
@property
def portgroup_metadata(self):
""" Get portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
return self._portgroup_metadata
@portgroup_metadata.setter
def portgroup_metadata(self, value):
""" Set portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
self._portgroup_metadata = value
@property
def nova_client_version(self):
""" Get nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
return self._nova_client_version
@nova_client_version.setter
def nova_client_version(self, value):
""" Set nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
self._nova_client_version = value
@property
def nova_metadata_service_auth_url(self):
""" Get nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
return self._nova_metadata_service_auth_url
@nova_metadata_service_auth_url.setter
def nova_metadata_service_auth_url(self, value):
""" Set nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
self._nova_metadata_service_auth_url = value
@property
def nova_metadata_service_endpoint(self):
""" Get nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
return self._nova_metadata_service_endpoint
@nova_metadata_service_endpoint.setter
def nova_metadata_service_endpoint(self, value):
""" Set nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
self._nova_metadata_service_endpoint = value
@property
def nova_metadata_service_password(self):
""" Get nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
return self._nova_metadata_service_password
@nova_metadata_service_password.setter
def nova_metadata_service_password(self, value):
""" Set nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
self._nova_metadata_service_password = value
@property
def nova_metadata_service_tenant(self):
""" Get nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
return self._nova_metadata_service_tenant
@nova_metadata_service_tenant.setter
def nova_metadata_service_tenant(self, value):
""" Set nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
self._nova_metadata_service_tenant = value
@property
def nova_metadata_service_username(self):
""" Get nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
return self._nova_metadata_service_username
@nova_metadata_service_username.setter
def nova_metadata_service_username(self, value):
""" Set nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
self._nova_metadata_service_username = value
@property
def nova_metadata_shared_secret(self):
""" Get nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
return self._nova_metadata_shared_secret
@nova_metadata_shared_secret.setter
def nova_metadata_shared_secret(self, value):
""" Set nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
self._nova_metadata_shared_secret = value
@property
def nova_region_name(self):
""" Get nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
return self._nova_region_name
@nova_region_name.setter
def nova_region_name(self, value):
""" Set nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
self._nova_region_name = value
@property
def primary_nuage_controller(self):
""" Get primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
return self._primary_nuage_controller
@primary_nuage_controller.setter
def primary_nuage_controller(self, value):
""" Set primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
self._primary_nuage_controller = value
@property
def vrs_id(self):
""" Get vrs_id value.
Notes:
VCenter Name or Id used by toolbox to identify the VRS virtual machine
This attribute is named `vrsId` in VSD API.
"""
return self._vrs_id
@vrs_id.setter
def vrs_id(self, value):
""" Set vrs_id value.
Notes:
VCenter Name or Id used by toolbox to identify the VRS virtual machine
This attribute is named `vrsId` in VSD API.
"""
self._vrs_id = value
@property
def vrs_password(self):
""" Get vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
return self._vrs_password
@vrs_password.setter
def vrs_password(self, value):
""" Set vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
self._vrs_password = value
@property
def vrs_user_name(self):
""" Get vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
return self._vrs_user_name
@vrs_user_name.setter
def vrs_user_name(self, value):
""" Set vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
self._vrs_user_name = value
@property
def associated_cluster_id(self):
""" Get associated_cluster_id value.
Notes:
The ID of the cluster to which this host is attached
This attribute is named `associatedClusterID` in VSD API.
"""
return self._associated_cluster_id
@associated_cluster_id.setter
def associated_cluster_id(self, value):
""" Set associated_cluster_id value.
Notes:
The ID of the cluster to which this host is attached
This attribute is named `associatedClusterID` in VSD API.
"""
self._associated_cluster_id = value
@property
def static_route(self):
""" Get static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
return self._static_route
@static_route.setter
def static_route(self, value):
""" Set static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
self._static_route = value
@property
def static_route_gateway(self):
""" Get static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
return self._static_route_gateway
@static_route_gateway.setter
def static_route_gateway(self, value):
""" Set static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
self._static_route_gateway = value
@property
def static_route_netmask(self):
""" Get static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
return self._static_route_netmask
@static_route_netmask.setter
def static_route_netmask(self, value):
""" Set static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
self._static_route_netmask = value
@property
def ntp_server1(self):
""" Get ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
return self._ntp_server1
@ntp_server1.setter
def ntp_server1(self, value):
""" Set ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
self._ntp_server1 = value
@property
def ntp_server2(self):
""" Get ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
return self._ntp_server2
@ntp_server2.setter
def ntp_server2(self, value):
""" Set ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
self._ntp_server2 = value
@property
def mtu(self):
""" Get mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
return self._mtu
@mtu.setter
def mtu(self, value):
""" Set mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
self._mtu = value
@property
def multi_vmssupport(self):
""" Get multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
return self._multi_vmssupport
@multi_vmssupport.setter
def multi_vmssupport(self, value):
""" Set multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
self._multi_vmssupport = value
@property
def multicast_receive_interface(self):
""" Get multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
return self._multicast_receive_interface
@multicast_receive_interface.setter
def multicast_receive_interface(self, value):
""" Set multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
self._multicast_receive_interface = value
@property
def multicast_receive_interface_ip(self):
""" Get multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
return self._multicast_receive_interface_ip
@multicast_receive_interface_ip.setter
def multicast_receive_interface_ip(self, value):
""" Set multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
self._multicast_receive_interface_ip = value
@property
def multicast_receive_interface_netmask(self):
""" Get multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
return self._multicast_receive_interface_netmask
@multicast_receive_interface_netmask.setter
def multicast_receive_interface_netmask(self, value):
""" Set multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
self._multicast_receive_interface_netmask = value
@property
def multicast_receive_range(self):
""" Get multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
return self._multicast_receive_range
@multicast_receive_range.setter
def multicast_receive_range(self, value):
""" Set multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
self._multicast_receive_range = value
@property
def multicast_send_interface(self):
""" Get multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
return self._multicast_send_interface
@multicast_send_interface.setter
def multicast_send_interface(self, value):
""" Set multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
self._multicast_send_interface = value
@property
def multicast_send_interface_ip(self):
""" Get multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
return self._multicast_send_interface_ip
@multicast_send_interface_ip.setter
def multicast_send_interface_ip(self, value):
""" Set multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
self._multicast_send_interface_ip = value
@property
def multicast_send_interface_netmask(self):
""" Get multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
return self._multicast_send_interface_netmask
@multicast_send_interface_netmask.setter
def multicast_send_interface_netmask(self, value):
""" Set multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
self._multicast_send_interface_netmask = value
@property
def multicast_source_portgroup(self):
""" Get multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
return self._multicast_source_portgroup
@multicast_source_portgroup.setter
def multicast_source_portgroup(self, value):
""" Set multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
self._multicast_source_portgroup = value
@property
def customized_script_url(self):
""" Get customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
return self._customized_script_url
@customized_script_url.setter
def customized_script_url(self, value):
""" Set customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
self._customized_script_url = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def hypervisor_ip(self):
""" Get hypervisor_ip value.
Notes:
IP Address of the Hypervisor
This attribute is named `hypervisorIP` in VSD API.
"""
return self._hypervisor_ip
@hypervisor_ip.setter
def hypervisor_ip(self, value):
""" Set hypervisor_ip value.
Notes:
IP Address of the Hypervisor
This attribute is named `hypervisorIP` in VSD API.
"""
self._hypervisor_ip = value
@property
def hypervisor_password(self):
""" Get hypervisor_password value.
Notes:
Hypervisor username
This attribute is named `hypervisorPassword` in VSD API.
"""
return self._hypervisor_password
@hypervisor_password.setter
def hypervisor_password(self, value):
""" Set hypervisor_password value.
Notes:
Hypervisor username
This attribute is named `hypervisorPassword` in VSD API.
"""
self._hypervisor_password = value
@property
def hypervisor_user(self):
""" Get hypervisor_user value.
Notes:
Hypervisor username
This attribute is named `hypervisorUser` in VSD API.
"""
return self._hypervisor_user
@hypervisor_user.setter
def hypervisor_user(self, value):
""" Set hypervisor_user value.
Notes:
Hypervisor username
This attribute is named `hypervisorUser` in VSD API.
"""
self._hypervisor_user = value
Ancestors (in MRO)
- NUVCenterHypervisor
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var allow_data_dhcp
Get allow_data_dhcp value.
Notes: Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
var allow_mgmt_dhcp
Get allow_mgmt_dhcp value.
Notes: Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
var arp_reply
Get arp_reply value.
Notes: Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
var associated_cluster_id
Get associated_cluster_id value.
Notes: The ID of the cluster to which this host is attached
This attribute is named `associatedClusterID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var customized_script_url
Get customized_script_url value.
Notes: To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
var data_dns1
Get data_dns1 value.
Notes: Data DNS 1
This attribute is named `dataDNS1` in VSD API.
var data_dns2
Get data_dns2 value.
Notes: Data DNS 2
This attribute is named `dataDNS2` in VSD API.
var data_gateway
Get data_gateway value.
Notes: Data Gateway
This attribute is named `dataGateway` in VSD API.
var data_ip_address
Get data_ip_address value.
Notes: Data IP Address
This attribute is named `dataIPAddress` in VSD API.
var data_netmask
Get data_netmask value.
Notes: Data NetMask
This attribute is named `dataNetmask` in VSD API.
var data_network_portgroup
Get data_network_portgroup value.
Notes: Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
var datapath_sync_timeout
Get datapath_sync_timeout value.
Notes: Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
var description
Get description value.
Notes: Description of the Hypervisor
var dhcp_relay_server
Get dhcp_relay_server value.
Notes: To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_eviction_threshold
Get flow_eviction_threshold value.
Notes: Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
var generic_split_activation
Get generic_split_activation value.
Notes: Split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
var global_metadatas
var hypervisor_ip
Get hypervisor_ip value.
Notes: IP Address of the Hypervisor
This attribute is named `hypervisorIP` in VSD API.
var hypervisor_password
Get hypervisor_password value.
Notes: Hypervisor username
This attribute is named `hypervisorPassword` in VSD API.
var hypervisor_user
Get hypervisor_user value.
Notes: Hypervisor username
This attribute is named `hypervisorUser` in VSD API.
var id
Get object id
var jobs
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_server_ip
Get metadata_server_ip value.
Notes: Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
var metadata_server_listen_port
Get metadata_server_listen_port value.
Notes: Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
var metadata_server_port
Get metadata_server_port value.
Notes: Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
var metadata_service_enabled
Get metadata_service_enabled value.
Notes: Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
var metadatas
var mgmt_dns1
Get mgmt_dns1 value.
Notes: DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
var mgmt_dns2
Get mgmt_dns2 value.
Notes: DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
var mgmt_gateway
Get mgmt_gateway value.
Notes: Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
var mgmt_ip_address
Get mgmt_ip_address value.
Notes: The Mangement IP address for VRS VM if needed to be given statically
This attribute is named `mgmtIPAddress` in VSD API.
var mgmt_netmask
Get mgmt_netmask value.
Notes: Netmask of the IP address above
This attribute is named `mgmtNetmask` in VSD API.
var mgmt_network_portgroup
Get mgmt_network_portgroup value.
Notes: Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
var mtu
Get mtu value.
Notes: Maximum Transmission Unit for eth2 interface
var multi_vmssupport
Get multi_vmssupport value.
Notes: Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
var multicast_receive_interface
Get multicast_receive_interface value.
Notes: Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
var multicast_receive_interface_ip
Get multicast_receive_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
var multicast_receive_interface_netmask
Get multicast_receive_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
var multicast_receive_range
Get multicast_receive_range value.
Notes: Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
var multicast_send_interface
Get multicast_send_interface value.
Notes: Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
var multicast_send_interface_ip
Get multicast_send_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
var multicast_send_interface_netmask
Get multicast_send_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
var multicast_source_portgroup
Get multicast_source_portgroup value.
Notes: Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
var name
Get name value.
Notes: Name of the Hypervisor
var network_uplink_interface
Get network_uplink_interface value.
Notes: Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
var network_uplink_interface_gateway
Get network_uplink_interface_gateway value.
Notes: Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
var network_uplink_interface_ip
Get network_uplink_interface_ip value.
Notes: Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
var network_uplink_interface_netmask
Get network_uplink_interface_netmask value.
Notes: Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
var nfs_log_server
Get nfs_log_server value.
Notes: IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
var nfs_mount_path
Get nfs_mount_path value.
Notes: Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
var nova_client_version
Get nova_client_version value.
Notes: Nova client Version
This attribute is named `novaClientVersion` in VSD API.
var nova_metadata_service_auth_url
Get nova_metadata_service_auth_url value.
Notes: Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
var nova_metadata_service_endpoint
Get nova_metadata_service_endpoint value.
Notes: Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
var nova_metadata_service_password
Get nova_metadata_service_password value.
Notes: Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
var nova_metadata_service_tenant
Get nova_metadata_service_tenant value.
Notes: Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
var nova_metadata_service_username
Get nova_metadata_service_username value.
Notes: Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
Get nova_metadata_shared_secret value.
Notes: Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
var nova_region_name
Get nova_region_name value.
Notes: Nova region name
This attribute is named `novaRegionName` in VSD API.
var ntp_server1
Get ntp_server1 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
var ntp_server2
Get ntp_server2 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var personality
Get personality value.
Notes: VRS/VRS-G
var portgroup_metadata
Get portgroup_metadata value.
Notes: Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
var primary_nuage_controller
Get primary_nuage_controller value.
Notes: IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
var secondary_nuage_controller
Get secondary_nuage_controller value.
Notes: IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
var separate_data_network
Get separate_data_network value.
Notes: Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
var site_id
Get site_id value.
Notes: Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
var static_route
Get static_route value.
Notes: static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
var static_route_gateway
Get static_route_gateway value.
Notes: Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
var static_route_netmask
Get static_route_netmask value.
Notes: Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
var toolbox_deployment_mode
Get toolbox_deployment_mode value.
Notes: Flag to specify if VRS is deployed using tool box.
This attribute is named `toolboxDeploymentMode` in VSD API.
var toolbox_group
Get toolbox_group value.
Notes: Deployment Toolbox Group.
This attribute is named `toolboxGroup` in VSD API.
var toolbox_ip
Get toolbox_ip value.
Notes: Deployment Toolbox IP.
This attribute is named `toolboxIP` in VSD API.
var toolbox_password
Get toolbox_password value.
Notes: Deployment Toolbox password.
This attribute is named `toolboxPassword` in VSD API.
var toolbox_user_name
Get toolbox_user_name value.
Notes: Deployment Toolbox username.
This attribute is named `toolboxUserName` in VSD API.
var v_require_nuage_metadata
Get v_require_nuage_metadata value.
Notes: Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
var vcenter_ip
Get vcenter_ip value.
Notes: IP Address of the VCenter.
This attribute is named `vCenterIP` in VSD API.
var vcenter_password
Get vcenter_password value.
Notes: Password for VCenter.
This attribute is named `vCenterPassword` in VSD API.
var vcenter_user
Get vcenter_user value.
Notes: Username for VCenter.
This attribute is named `vCenterUser` in VSD API.
var vm_network_portgroup
Get vm_network_portgroup value.
Notes: VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
var vrs_address_ranges
var vrs_id
Get vrs_id value.
Notes: VCenter Name or Id used by toolbox to identify the VRS virtual machine
This attribute is named `vrsId` in VSD API.
var vrs_password
Get vrs_password value.
Notes: VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
var vrs_user_name
Get vrs_user_name value.
Notes: VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VCenterHypervisor instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vcenterhypervisor = NUVCenterHypervisor(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterHypervisor') >>> vcenterhypervisor = NUVCenterHypervisor(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VCenterHypervisor instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcenterhypervisor = NUVCenterHypervisor(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterHypervisor')
>>> vcenterhypervisor = NUVCenterHypervisor(data=my_dict)
"""
super(NUVCenterHypervisor, self).__init__()
# Read/Write Attributes
self._vcenter_ip = None
self._vcenter_password = None
self._vcenter_user = None
self._arp_reply = None
self._v_require_nuage_metadata = None
self._name = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_ip_address = None
self._data_netmask = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._description = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_ip_address = None
self._mgmt_netmask = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._toolbox_deployment_mode = None
self._toolbox_group = None
self._toolbox_ip = None
self._toolbox_password = None
self._toolbox_user_name = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_id = None
self._vrs_password = None
self._vrs_user_name = None
self._associated_cluster_id = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self._hypervisor_ip = None
self._hypervisor_password = None
self._hypervisor_user = None
self.expose_attribute(local_name="vcenter_ip", remote_name="vCenterIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vcenter_password", remote_name="vCenterPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vcenter_user", remote_name="vCenterUser", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_ip_address", remote_name="dataIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_netmask", remote_name="dataNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_ip_address", remote_name="mgmtIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_netmask", remote_name="mgmtNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="toolbox_deployment_mode", remote_name="toolboxDeploymentMode", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_group", remote_name="toolboxGroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_ip", remote_name="toolboxIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_password", remote_name="toolboxPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="toolbox_user_name", remote_name="toolboxUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_id", remote_name="vrsId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_cluster_id", remote_name="associatedClusterID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="hypervisor_ip", remote_name="hypervisorIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="hypervisor_password", remote_name="hypervisorPassword", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="hypervisor_user", remote_name="hypervisorUser", attribute_type=str, is_required=True, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVCenterVRSConfig
Represents a VCenterVRSConfig in the VSD
Notes: Default VRS Configuration parameters
class NUVCenterVRSConfig(NURESTObject):
""" Represents a VCenterVRSConfig in the VSD
Notes:
Default VRS Configuration parameters
"""
__rest_name__ = "vrsconfig"
__resource_name__ = "vrsconfigs"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VCenterVRSConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcentervrsconfig = NUVCenterVRSConfig(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterVRSConfig')
>>> vcentervrsconfig = NUVCenterVRSConfig(data=my_dict)
"""
super(NUVCenterVRSConfig, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_password = None
self._vrs_user_name = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def arp_reply(self):
""" Get arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
return self._arp_reply
@arp_reply.setter
def arp_reply(self, value):
""" Set arp_reply value.
Notes:
Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
"""
self._arp_reply = value
@property
def v_require_nuage_metadata(self):
""" Get v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
return self._v_require_nuage_metadata
@v_require_nuage_metadata.setter
def v_require_nuage_metadata(self, value):
""" Set v_require_nuage_metadata value.
Notes:
Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
"""
self._v_require_nuage_metadata = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def data_dns1(self):
""" Get data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
return self._data_dns1
@data_dns1.setter
def data_dns1(self, value):
""" Set data_dns1 value.
Notes:
Data DNS 1
This attribute is named `dataDNS1` in VSD API.
"""
self._data_dns1 = value
@property
def data_dns2(self):
""" Get data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
return self._data_dns2
@data_dns2.setter
def data_dns2(self, value):
""" Set data_dns2 value.
Notes:
Data DNS 2
This attribute is named `dataDNS2` in VSD API.
"""
self._data_dns2 = value
@property
def data_gateway(self):
""" Get data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
return self._data_gateway
@data_gateway.setter
def data_gateway(self, value):
""" Set data_gateway value.
Notes:
Data Gateway
This attribute is named `dataGateway` in VSD API.
"""
self._data_gateway = value
@property
def data_network_portgroup(self):
""" Get data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
return self._data_network_portgroup
@data_network_portgroup.setter
def data_network_portgroup(self, value):
""" Set data_network_portgroup value.
Notes:
Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
"""
self._data_network_portgroup = value
@property
def datapath_sync_timeout(self):
""" Get datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
return self._datapath_sync_timeout
@datapath_sync_timeout.setter
def datapath_sync_timeout(self, value):
""" Set datapath_sync_timeout value.
Notes:
Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
"""
self._datapath_sync_timeout = value
@property
def secondary_nuage_controller(self):
""" Get secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
return self._secondary_nuage_controller
@secondary_nuage_controller.setter
def secondary_nuage_controller(self, value):
""" Set secondary_nuage_controller value.
Notes:
IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
"""
self._secondary_nuage_controller = value
@property
def generic_split_activation(self):
""" Get generic_split_activation value.
Notes:
Whether split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
return self._generic_split_activation
@generic_split_activation.setter
def generic_split_activation(self, value):
""" Set generic_split_activation value.
Notes:
Whether split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
"""
self._generic_split_activation = value
@property
def separate_data_network(self):
""" Get separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
return self._separate_data_network
@separate_data_network.setter
def separate_data_network(self, value):
""" Set separate_data_network value.
Notes:
Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
"""
self._separate_data_network = value
@property
def personality(self):
""" Get personality value.
Notes:
VRS/VRS-G
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
VRS/VRS-G
"""
self._personality = value
@property
def metadata_server_ip(self):
""" Get metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
return self._metadata_server_ip
@metadata_server_ip.setter
def metadata_server_ip(self, value):
""" Set metadata_server_ip value.
Notes:
Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
"""
self._metadata_server_ip = value
@property
def metadata_server_listen_port(self):
""" Get metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
return self._metadata_server_listen_port
@metadata_server_listen_port.setter
def metadata_server_listen_port(self, value):
""" Set metadata_server_listen_port value.
Notes:
Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
"""
self._metadata_server_listen_port = value
@property
def metadata_server_port(self):
""" Get metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
return self._metadata_server_port
@metadata_server_port.setter
def metadata_server_port(self, value):
""" Set metadata_server_port value.
Notes:
Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
"""
self._metadata_server_port = value
@property
def metadata_service_enabled(self):
""" Get metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
return self._metadata_service_enabled
@metadata_service_enabled.setter
def metadata_service_enabled(self, value):
""" Set metadata_service_enabled value.
Notes:
Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
"""
self._metadata_service_enabled = value
@property
def network_uplink_interface(self):
""" Get network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
return self._network_uplink_interface
@network_uplink_interface.setter
def network_uplink_interface(self, value):
""" Set network_uplink_interface value.
Notes:
Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
"""
self._network_uplink_interface = value
@property
def network_uplink_interface_gateway(self):
""" Get network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
return self._network_uplink_interface_gateway
@network_uplink_interface_gateway.setter
def network_uplink_interface_gateway(self, value):
""" Set network_uplink_interface_gateway value.
Notes:
Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
"""
self._network_uplink_interface_gateway = value
@property
def network_uplink_interface_ip(self):
""" Get network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
return self._network_uplink_interface_ip
@network_uplink_interface_ip.setter
def network_uplink_interface_ip(self, value):
""" Set network_uplink_interface_ip value.
Notes:
Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
"""
self._network_uplink_interface_ip = value
@property
def network_uplink_interface_netmask(self):
""" Get network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
return self._network_uplink_interface_netmask
@network_uplink_interface_netmask.setter
def network_uplink_interface_netmask(self, value):
""" Set network_uplink_interface_netmask value.
Notes:
Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
"""
self._network_uplink_interface_netmask = value
@property
def nfs_log_server(self):
""" Get nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
return self._nfs_log_server
@nfs_log_server.setter
def nfs_log_server(self, value):
""" Set nfs_log_server value.
Notes:
IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
"""
self._nfs_log_server = value
@property
def nfs_mount_path(self):
""" Get nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
return self._nfs_mount_path
@nfs_mount_path.setter
def nfs_mount_path(self, value):
""" Set nfs_mount_path value.
Notes:
Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
"""
self._nfs_mount_path = value
@property
def mgmt_dns1(self):
""" Get mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
return self._mgmt_dns1
@mgmt_dns1.setter
def mgmt_dns1(self, value):
""" Set mgmt_dns1 value.
Notes:
DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
"""
self._mgmt_dns1 = value
@property
def mgmt_dns2(self):
""" Get mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
return self._mgmt_dns2
@mgmt_dns2.setter
def mgmt_dns2(self, value):
""" Set mgmt_dns2 value.
Notes:
DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
"""
self._mgmt_dns2 = value
@property
def mgmt_gateway(self):
""" Get mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
return self._mgmt_gateway
@mgmt_gateway.setter
def mgmt_gateway(self, value):
""" Set mgmt_gateway value.
Notes:
Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
"""
self._mgmt_gateway = value
@property
def mgmt_network_portgroup(self):
""" Get mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
return self._mgmt_network_portgroup
@mgmt_network_portgroup.setter
def mgmt_network_portgroup(self, value):
""" Set mgmt_network_portgroup value.
Notes:
Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
"""
self._mgmt_network_portgroup = value
@property
def dhcp_relay_server(self):
""" Get dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
return self._dhcp_relay_server
@dhcp_relay_server.setter
def dhcp_relay_server(self, value):
""" Set dhcp_relay_server value.
Notes:
To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
"""
self._dhcp_relay_server = value
@property
def site_id(self):
""" Get site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
return self._site_id
@site_id.setter
def site_id(self, value):
""" Set site_id value.
Notes:
Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
"""
self._site_id = value
@property
def allow_data_dhcp(self):
""" Get allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
return self._allow_data_dhcp
@allow_data_dhcp.setter
def allow_data_dhcp(self, value):
""" Set allow_data_dhcp value.
Notes:
Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
"""
self._allow_data_dhcp = value
@property
def allow_mgmt_dhcp(self):
""" Get allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
return self._allow_mgmt_dhcp
@allow_mgmt_dhcp.setter
def allow_mgmt_dhcp(self, value):
""" Set allow_mgmt_dhcp value.
Notes:
Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
"""
self._allow_mgmt_dhcp = value
@property
def flow_eviction_threshold(self):
""" Get flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
return self._flow_eviction_threshold
@flow_eviction_threshold.setter
def flow_eviction_threshold(self, value):
""" Set flow_eviction_threshold value.
Notes:
Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
"""
self._flow_eviction_threshold = value
@property
def vm_network_portgroup(self):
""" Get vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
return self._vm_network_portgroup
@vm_network_portgroup.setter
def vm_network_portgroup(self, value):
""" Set vm_network_portgroup value.
Notes:
VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
"""
self._vm_network_portgroup = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def portgroup_metadata(self):
""" Get portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
return self._portgroup_metadata
@portgroup_metadata.setter
def portgroup_metadata(self, value):
""" Set portgroup_metadata value.
Notes:
Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
"""
self._portgroup_metadata = value
@property
def nova_client_version(self):
""" Get nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
return self._nova_client_version
@nova_client_version.setter
def nova_client_version(self, value):
""" Set nova_client_version value.
Notes:
Nova client Version
This attribute is named `novaClientVersion` in VSD API.
"""
self._nova_client_version = value
@property
def nova_metadata_service_auth_url(self):
""" Get nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
return self._nova_metadata_service_auth_url
@nova_metadata_service_auth_url.setter
def nova_metadata_service_auth_url(self, value):
""" Set nova_metadata_service_auth_url value.
Notes:
Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
"""
self._nova_metadata_service_auth_url = value
@property
def nova_metadata_service_endpoint(self):
""" Get nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
return self._nova_metadata_service_endpoint
@nova_metadata_service_endpoint.setter
def nova_metadata_service_endpoint(self, value):
""" Set nova_metadata_service_endpoint value.
Notes:
Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
"""
self._nova_metadata_service_endpoint = value
@property
def nova_metadata_service_password(self):
""" Get nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
return self._nova_metadata_service_password
@nova_metadata_service_password.setter
def nova_metadata_service_password(self, value):
""" Set nova_metadata_service_password value.
Notes:
Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
"""
self._nova_metadata_service_password = value
@property
def nova_metadata_service_tenant(self):
""" Get nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
return self._nova_metadata_service_tenant
@nova_metadata_service_tenant.setter
def nova_metadata_service_tenant(self, value):
""" Set nova_metadata_service_tenant value.
Notes:
Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
"""
self._nova_metadata_service_tenant = value
@property
def nova_metadata_service_username(self):
""" Get nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
return self._nova_metadata_service_username
@nova_metadata_service_username.setter
def nova_metadata_service_username(self, value):
""" Set nova_metadata_service_username value.
Notes:
Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
"""
self._nova_metadata_service_username = value
@property
def nova_metadata_shared_secret(self):
""" Get nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
return self._nova_metadata_shared_secret
@nova_metadata_shared_secret.setter
def nova_metadata_shared_secret(self, value):
""" Set nova_metadata_shared_secret value.
Notes:
Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
"""
self._nova_metadata_shared_secret = value
@property
def nova_region_name(self):
""" Get nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
return self._nova_region_name
@nova_region_name.setter
def nova_region_name(self, value):
""" Set nova_region_name value.
Notes:
Nova region name
This attribute is named `novaRegionName` in VSD API.
"""
self._nova_region_name = value
@property
def primary_nuage_controller(self):
""" Get primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
return self._primary_nuage_controller
@primary_nuage_controller.setter
def primary_nuage_controller(self, value):
""" Set primary_nuage_controller value.
Notes:
IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
"""
self._primary_nuage_controller = value
@property
def vrs_password(self):
""" Get vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
return self._vrs_password
@vrs_password.setter
def vrs_password(self, value):
""" Set vrs_password value.
Notes:
VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
"""
self._vrs_password = value
@property
def vrs_user_name(self):
""" Get vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
return self._vrs_user_name
@vrs_user_name.setter
def vrs_user_name(self, value):
""" Set vrs_user_name value.
Notes:
VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
"""
self._vrs_user_name = value
@property
def static_route(self):
""" Get static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
return self._static_route
@static_route.setter
def static_route(self, value):
""" Set static_route value.
Notes:
static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
"""
self._static_route = value
@property
def static_route_gateway(self):
""" Get static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
return self._static_route_gateway
@static_route_gateway.setter
def static_route_gateway(self, value):
""" Set static_route_gateway value.
Notes:
Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
"""
self._static_route_gateway = value
@property
def static_route_netmask(self):
""" Get static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
return self._static_route_netmask
@static_route_netmask.setter
def static_route_netmask(self, value):
""" Set static_route_netmask value.
Notes:
Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
"""
self._static_route_netmask = value
@property
def ntp_server1(self):
""" Get ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
return self._ntp_server1
@ntp_server1.setter
def ntp_server1(self, value):
""" Set ntp_server1 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
"""
self._ntp_server1 = value
@property
def ntp_server2(self):
""" Get ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
return self._ntp_server2
@ntp_server2.setter
def ntp_server2(self, value):
""" Set ntp_server2 value.
Notes:
IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
"""
self._ntp_server2 = value
@property
def mtu(self):
""" Get mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
return self._mtu
@mtu.setter
def mtu(self, value):
""" Set mtu value.
Notes:
Maximum Transmission Unit for eth2 interface
"""
self._mtu = value
@property
def multi_vmssupport(self):
""" Get multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
return self._multi_vmssupport
@multi_vmssupport.setter
def multi_vmssupport(self, value):
""" Set multi_vmssupport value.
Notes:
Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
"""
self._multi_vmssupport = value
@property
def multicast_receive_interface(self):
""" Get multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
return self._multicast_receive_interface
@multicast_receive_interface.setter
def multicast_receive_interface(self, value):
""" Set multicast_receive_interface value.
Notes:
Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
"""
self._multicast_receive_interface = value
@property
def multicast_receive_interface_ip(self):
""" Get multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
return self._multicast_receive_interface_ip
@multicast_receive_interface_ip.setter
def multicast_receive_interface_ip(self, value):
""" Set multicast_receive_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
"""
self._multicast_receive_interface_ip = value
@property
def multicast_receive_interface_netmask(self):
""" Get multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
return self._multicast_receive_interface_netmask
@multicast_receive_interface_netmask.setter
def multicast_receive_interface_netmask(self, value):
""" Set multicast_receive_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
"""
self._multicast_receive_interface_netmask = value
@property
def multicast_receive_range(self):
""" Get multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
return self._multicast_receive_range
@multicast_receive_range.setter
def multicast_receive_range(self, value):
""" Set multicast_receive_range value.
Notes:
Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
"""
self._multicast_receive_range = value
@property
def multicast_send_interface(self):
""" Get multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
return self._multicast_send_interface
@multicast_send_interface.setter
def multicast_send_interface(self, value):
""" Set multicast_send_interface value.
Notes:
Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
"""
self._multicast_send_interface = value
@property
def multicast_send_interface_ip(self):
""" Get multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
return self._multicast_send_interface_ip
@multicast_send_interface_ip.setter
def multicast_send_interface_ip(self, value):
""" Set multicast_send_interface_ip value.
Notes:
IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
"""
self._multicast_send_interface_ip = value
@property
def multicast_send_interface_netmask(self):
""" Get multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
return self._multicast_send_interface_netmask
@multicast_send_interface_netmask.setter
def multicast_send_interface_netmask(self, value):
""" Set multicast_send_interface_netmask value.
Notes:
Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
"""
self._multicast_send_interface_netmask = value
@property
def multicast_source_portgroup(self):
""" Get multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
return self._multicast_source_portgroup
@multicast_source_portgroup.setter
def multicast_source_portgroup(self, value):
""" Set multicast_source_portgroup value.
Notes:
Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
"""
self._multicast_source_portgroup = value
@property
def customized_script_url(self):
""" Get customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
return self._customized_script_url
@customized_script_url.setter
def customized_script_url(self, value):
""" Set customized_script_url value.
Notes:
To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
"""
self._customized_script_url = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVCenterVRSConfig
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var allow_data_dhcp
Get allow_data_dhcp value.
Notes: Whether to get the Data IP for the VRS VM from DHCP or statically
This attribute is named `allowDataDHCP` in VSD API.
var allow_mgmt_dhcp
Get allow_mgmt_dhcp value.
Notes: Whether to get the management IP for the VRS VM from DHCP or statically
This attribute is named `allowMgmtDHCP` in VSD API.
var arp_reply
Get arp_reply value.
Notes: Whether ARP Reply is enabled/disabled
This attribute is named `ARPReply` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var customized_script_url
Get customized_script_url value.
Notes: To provide a URL to install a custom app on VRS
This attribute is named `customizedScriptURL` in VSD API.
var data_dns1
Get data_dns1 value.
Notes: Data DNS 1
This attribute is named `dataDNS1` in VSD API.
var data_dns2
Get data_dns2 value.
Notes: Data DNS 2
This attribute is named `dataDNS2` in VSD API.
var data_gateway
Get data_gateway value.
Notes: Data Gateway
This attribute is named `dataGateway` in VSD API.
var data_network_portgroup
Get data_network_portgroup value.
Notes: Data Network Port Group
This attribute is named `dataNetworkPortgroup` in VSD API.
var datapath_sync_timeout
Get datapath_sync_timeout value.
Notes: Datapath Sync Timeout
This attribute is named `datapathSyncTimeout` in VSD API.
var dhcp_relay_server
Get dhcp_relay_server value.
Notes: To provide IP address of the interface from which you will connect to the DHCP relay server
This attribute is named `dhcpRelayServer` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var flow_eviction_threshold
Get flow_eviction_threshold value.
Notes: Flow Eviction Threshold
This attribute is named `flowEvictionThreshold` in VSD API.
var generic_split_activation
Get generic_split_activation value.
Notes: Whether split-activation is needed from VRO
This attribute is named `genericSplitActivation` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadata_server_ip
Get metadata_server_ip value.
Notes: Metadata Server IP
This attribute is named `metadataServerIP` in VSD API.
var metadata_server_listen_port
Get metadata_server_listen_port value.
Notes: Metadata Server Listen Port
This attribute is named `metadataServerListenPort` in VSD API.
var metadata_server_port
Get metadata_server_port value.
Notes: Metadata Server Port
This attribute is named `metadataServerPort` in VSD API.
var metadata_service_enabled
Get metadata_service_enabled value.
Notes: Metadata Service Enabled
This attribute is named `metadataServiceEnabled` in VSD API.
var metadatas
var mgmt_dns1
Get mgmt_dns1 value.
Notes: DNS server 1
This attribute is named `mgmtDNS1` in VSD API.
var mgmt_dns2
Get mgmt_dns2 value.
Notes: DNS server 2
This attribute is named `mgmtDNS2` in VSD API.
var mgmt_gateway
Get mgmt_gateway value.
Notes: Gateway for the IP address
This attribute is named `mgmtGateway` in VSD API.
var mgmt_network_portgroup
Get mgmt_network_portgroup value.
Notes: Management Network Port group
This attribute is named `mgmtNetworkPortgroup` in VSD API.
var mtu
Get mtu value.
Notes: Maximum Transmission Unit for eth2 interface
var multi_vmssupport
Get multi_vmssupport value.
Notes: Whether Multi VM is to be used or not
This attribute is named `multiVMSsupport` in VSD API.
var multicast_receive_interface
Get multicast_receive_interface value.
Notes: Multicast Receive Interface
This attribute is named `multicastReceiveInterface` in VSD API.
var multicast_receive_interface_ip
Get multicast_receive_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastReceiveInterfaceIP` in VSD API.
var multicast_receive_interface_netmask
Get multicast_receive_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastReceiveInterfaceNetmask` in VSD API.
var multicast_receive_range
Get multicast_receive_range value.
Notes: Allowed Range to receive the Multicast traffic from
This attribute is named `multicastReceiveRange` in VSD API.
var multicast_send_interface
Get multicast_send_interface value.
Notes: Multicast Send Interface
This attribute is named `multicastSendInterface` in VSD API.
var multicast_send_interface_ip
Get multicast_send_interface_ip value.
Notes: IP address for eth3 interface
This attribute is named `multicastSendInterfaceIP` in VSD API.
var multicast_send_interface_netmask
Get multicast_send_interface_netmask value.
Notes: Multicast Interface netmask
This attribute is named `multicastSendInterfaceNetmask` in VSD API.
var multicast_source_portgroup
Get multicast_source_portgroup value.
Notes: Multi Cast Source Port Group Name
This attribute is named `multicastSourcePortgroup` in VSD API.
var network_uplink_interface
Get network_uplink_interface value.
Notes: Network Upling Interface to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterface` in VSD API.
var network_uplink_interface_gateway
Get network_uplink_interface_gateway value.
Notes: Network Uplink Interface Gateway
This attribute is named `networkUplinkInterfaceGateway` in VSD API.
var network_uplink_interface_ip
Get network_uplink_interface_ip value.
Notes: Ip Address to support PAT/NAT with no tunnels on VRS-VM
This attribute is named `networkUplinkInterfaceIp` in VSD API.
var network_uplink_interface_netmask
Get network_uplink_interface_netmask value.
Notes: Network Uplink Interface Netmask
This attribute is named `networkUplinkInterfaceNetmask` in VSD API.
var nfs_log_server
Get nfs_log_server value.
Notes: IP address of NFS server to send the VRS log
This attribute is named `nfsLogServer` in VSD API.
var nfs_mount_path
Get nfs_mount_path value.
Notes: Location to mount the NFS server
This attribute is named `nfsMountPath` in VSD API.
var nova_client_version
Get nova_client_version value.
Notes: Nova client Version
This attribute is named `novaClientVersion` in VSD API.
var nova_metadata_service_auth_url
Get nova_metadata_service_auth_url value.
Notes: Nova metadata service auth url
This attribute is named `novaMetadataServiceAuthUrl` in VSD API.
var nova_metadata_service_endpoint
Get nova_metadata_service_endpoint value.
Notes: Nova metadata service endpoint
This attribute is named `novaMetadataServiceEndpoint` in VSD API.
var nova_metadata_service_password
Get nova_metadata_service_password value.
Notes: Nova metadata service password
This attribute is named `novaMetadataServicePassword` in VSD API.
var nova_metadata_service_tenant
Get nova_metadata_service_tenant value.
Notes: Nova metadata service tenant
This attribute is named `novaMetadataServiceTenant` in VSD API.
var nova_metadata_service_username
Get nova_metadata_service_username value.
Notes: Nova metadata service username
This attribute is named `novaMetadataServiceUsername` in VSD API.
Get nova_metadata_shared_secret value.
Notes: Nova metadata shared secret
This attribute is named `novaMetadataSharedSecret` in VSD API.
var nova_region_name
Get nova_region_name value.
Notes: Nova region name
This attribute is named `novaRegionName` in VSD API.
var ntp_server1
Get ntp_server1 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer1` in VSD API.
var ntp_server2
Get ntp_server2 value.
Notes: IP of the NTP server 1
This attribute is named `ntpServer2` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var personality
Get personality value.
Notes: VRS/VRS-G
var portgroup_metadata
Get portgroup_metadata value.
Notes: Port Group Meta data
This attribute is named `portgroupMetadata` in VSD API.
var primary_nuage_controller
Get primary_nuage_controller value.
Notes: IP address of the primary Controller (VSC)
This attribute is named `primaryNuageController` in VSD API.
var secondary_nuage_controller
Get secondary_nuage_controller value.
Notes: IP address of the secondary Controller (VSC)
This attribute is named `secondaryNuageController` in VSD API.
var separate_data_network
Get separate_data_network value.
Notes: Whether Data will use the management network or not
This attribute is named `separateDataNetwork` in VSD API.
var site_id
Get site_id value.
Notes: Site ID field for object profiles to support VSD Geo-redundancy
This attribute is named `siteId` in VSD API.
var static_route
Get static_route value.
Notes: static route to be configured in the VRS
This attribute is named `staticRoute` in VSD API.
var static_route_gateway
Get static_route_gateway value.
Notes: Gateway for the static route given above
This attribute is named `staticRouteGateway` in VSD API.
var static_route_netmask
Get static_route_netmask value.
Notes: Nova region name
This attribute is named `staticRouteNetmask` in VSD API.
var v_require_nuage_metadata
Get v_require_nuage_metadata value.
Notes: Whether split-activation or not (Openstack/CloudStack)
This attribute is named `vRequireNuageMetadata` in VSD API.
var vm_network_portgroup
Get vm_network_portgroup value.
Notes: VM Network Port Group Name
This attribute is named `vmNetworkPortgroup` in VSD API.
var vrs_address_ranges
var vrs_password
Get vrs_password value.
Notes: VRS password to be used by toolbox to communicate with VRS
This attribute is named `vrsPassword` in VSD API.
var vrs_user_name
Get vrs_user_name value.
Notes: VRS user name to be used by toolbox to communicate with VRS
This attribute is named `vrsUserName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VCenterVRSConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vcentervrsconfig = NUVCenterVRSConfig(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterVRSConfig') >>> vcentervrsconfig = NUVCenterVRSConfig(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VCenterVRSConfig instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vcentervrsconfig = NUVCenterVRSConfig(id=u'xxxx-xxx-xxx-xxx', name=u'VCenterVRSConfig')
>>> vcentervrsconfig = NUVCenterVRSConfig(data=my_dict)
"""
super(NUVCenterVRSConfig, self).__init__()
# Read/Write Attributes
self._arp_reply = None
self._v_require_nuage_metadata = None
self._last_updated_by = None
self._data_dns1 = None
self._data_dns2 = None
self._data_gateway = None
self._data_network_portgroup = None
self._datapath_sync_timeout = None
self._secondary_nuage_controller = None
self._generic_split_activation = None
self._separate_data_network = None
self._personality = None
self._metadata_server_ip = None
self._metadata_server_listen_port = None
self._metadata_server_port = None
self._metadata_service_enabled = None
self._network_uplink_interface = None
self._network_uplink_interface_gateway = None
self._network_uplink_interface_ip = None
self._network_uplink_interface_netmask = None
self._nfs_log_server = None
self._nfs_mount_path = None
self._mgmt_dns1 = None
self._mgmt_dns2 = None
self._mgmt_gateway = None
self._mgmt_network_portgroup = None
self._dhcp_relay_server = None
self._site_id = None
self._allow_data_dhcp = None
self._allow_mgmt_dhcp = None
self._flow_eviction_threshold = None
self._vm_network_portgroup = None
self._entity_scope = None
self._portgroup_metadata = None
self._nova_client_version = None
self._nova_metadata_service_auth_url = None
self._nova_metadata_service_endpoint = None
self._nova_metadata_service_password = None
self._nova_metadata_service_tenant = None
self._nova_metadata_service_username = None
self._nova_metadata_shared_secret = None
self._nova_region_name = None
self._primary_nuage_controller = None
self._vrs_password = None
self._vrs_user_name = None
self._static_route = None
self._static_route_gateway = None
self._static_route_netmask = None
self._ntp_server1 = None
self._ntp_server2 = None
self._mtu = None
self._multi_vmssupport = None
self._multicast_receive_interface = None
self._multicast_receive_interface_ip = None
self._multicast_receive_interface_netmask = None
self._multicast_receive_range = None
self._multicast_send_interface = None
self._multicast_send_interface_ip = None
self._multicast_send_interface_netmask = None
self._multicast_source_portgroup = None
self._customized_script_url = None
self._external_id = None
self.expose_attribute(local_name="arp_reply", remote_name="ARPReply", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="v_require_nuage_metadata", remote_name="vRequireNuageMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns1", remote_name="dataDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_dns2", remote_name="dataDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_gateway", remote_name="dataGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="data_network_portgroup", remote_name="dataNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="datapath_sync_timeout", remote_name="datapathSyncTimeout", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="secondary_nuage_controller", remote_name="secondaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="generic_split_activation", remote_name="genericSplitActivation", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="separate_data_network", remote_name="separateDataNetwork", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_ip", remote_name="metadataServerIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_listen_port", remote_name="metadataServerListenPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_server_port", remote_name="metadataServerPort", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="metadata_service_enabled", remote_name="metadataServiceEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface", remote_name="networkUplinkInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_gateway", remote_name="networkUplinkInterfaceGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_ip", remote_name="networkUplinkInterfaceIp", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_uplink_interface_netmask", remote_name="networkUplinkInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_log_server", remote_name="nfsLogServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nfs_mount_path", remote_name="nfsMountPath", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns1", remote_name="mgmtDNS1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_dns2", remote_name="mgmtDNS2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_gateway", remote_name="mgmtGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mgmt_network_portgroup", remote_name="mgmtNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="dhcp_relay_server", remote_name="dhcpRelayServer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_id", remote_name="siteId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_data_dhcp", remote_name="allowDataDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="allow_mgmt_dhcp", remote_name="allowMgmtDHCP", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="flow_eviction_threshold", remote_name="flowEvictionThreshold", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="vm_network_portgroup", remote_name="vmNetworkPortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="portgroup_metadata", remote_name="portgroupMetadata", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_client_version", remote_name="novaClientVersion", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_auth_url", remote_name="novaMetadataServiceAuthUrl", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_endpoint", remote_name="novaMetadataServiceEndpoint", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_password", remote_name="novaMetadataServicePassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_tenant", remote_name="novaMetadataServiceTenant", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_service_username", remote_name="novaMetadataServiceUsername", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_metadata_shared_secret", remote_name="novaMetadataSharedSecret", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="nova_region_name", remote_name="novaRegionName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="primary_nuage_controller", remote_name="primaryNuageController", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_password", remote_name="vrsPassword", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrs_user_name", remote_name="vrsUserName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route", remote_name="staticRoute", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_gateway", remote_name="staticRouteGateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="static_route_netmask", remote_name="staticRouteNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server1", remote_name="ntpServer1", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ntp_server2", remote_name="ntpServer2", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mtu", remote_name="mtu", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_vmssupport", remote_name="multiVMSsupport", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface", remote_name="multicastReceiveInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_ip", remote_name="multicastReceiveInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_interface_netmask", remote_name="multicastReceiveInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_receive_range", remote_name="multicastReceiveRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface", remote_name="multicastSendInterface", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_ip", remote_name="multicastSendInterfaceIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_send_interface_netmask", remote_name="multicastSendInterfaceNetmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast_source_portgroup", remote_name="multicastSourcePortgroup", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="customized_script_url", remote_name="customizedScriptURL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrs_address_ranges = NUVRSAddressRangesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVLAN
Represents a VLAN in the VSD
Notes: Represents VLAN object under a given PORT object.
class NUVLAN(NURESTObject):
""" Represents a VLAN in the VSD
Notes:
Represents VLAN object under a given PORT object.
"""
__rest_name__ = "vlan"
__resource_name__ = "vlans"
## Constants
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_STATUS_READY = "READY"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_STATUS_INITIALIZED = "INITIALIZED"
CONST_STATUS_MISMATCH = "MISMATCH"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_STATUS_ORPHAN = "ORPHAN"
def __init__(self, **kwargs):
""" Initializes a VLAN instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vlan = NUVLAN(id=u'xxxx-xxx-xxx-xxx', name=u'VLAN')
>>> vlan = NUVLAN(data=my_dict)
"""
super(NUVLAN, self).__init__()
# Read/Write Attributes
self._value = None
self._last_updated_by = None
self._gateway_id = None
self._readonly = None
self._template_id = None
self._permitted_action = None
self._description = None
self._restricted = None
self._entity_scope = None
self._vport_id = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="value", remote_name="value", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="readonly", remote_name="readonly", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="restricted", remote_name="restricted", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="vport_id", remote_name="vportID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def value(self):
""" Get value value.
Notes:
value of VLAN
"""
return self._value
@value.setter
def value(self, value):
""" Set value value.
Notes:
value of VLAN
"""
self._value = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway_id(self):
""" Get gateway_id value.
Notes:
The Gateway associated with this VLAN . This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
return self._gateway_id
@gateway_id.setter
def gateway_id(self, value):
""" Set gateway_id value.
Notes:
The Gateway associated with this VLAN . This is a read only attribute
This attribute is named `gatewayID` in VSD API.
"""
self._gateway_id = value
@property
def readonly(self):
""" Get readonly value.
Notes:
Determines whether this entity is read only. Read only objects cannot be modified or deleted.
"""
return self._readonly
@readonly.setter
def readonly(self, value):
""" Set readonly value.
Notes:
Determines whether this entity is read only. Read only objects cannot be modified or deleted.
"""
self._readonly = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def restricted(self):
""" Get restricted value.
Notes:
Determines whether this entity can be used in associations with other properties.
"""
return self._restricted
@restricted.setter
def restricted(self, value):
""" Set restricted value.
Notes:
Determines whether this entity can be used in associations with other properties.
"""
self._restricted = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def vport_id(self):
""" Get vport_id value.
Notes:
The Vport associated with this VLAN . This is a read only attribute
This attribute is named `vportID` in VSD API.
"""
return self._vport_id
@vport_id.setter
def vport_id(self, value):
""" Set vport_id value.
Notes:
The Vport associated with this VLAN . This is a read only attribute
This attribute is named `vportID` in VSD API.
"""
self._vport_id = value
@property
def use_user_mnemonic(self):
""" Get use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
return self._use_user_mnemonic
@use_user_mnemonic.setter
def use_user_mnemonic(self, value):
""" Set use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
self._use_user_mnemonic = value
@property
def user_mnemonic(self):
""" Get user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
return self._user_mnemonic
@user_mnemonic.setter
def user_mnemonic(self, value):
""" Set user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
self._user_mnemonic = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def status(self):
""" Get status value.
Notes:
Status of the VLAN.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Status of the VLAN.
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUVLAN
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_STATUS_INITIALIZED
var CONST_STATUS_MISMATCH
var CONST_STATUS_ORPHAN
var CONST_STATUS_READY
var resource_name
var rest_name
Instance variables
var alarms
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway_id
Get gateway_id value.
Notes: The Gateway associated with this VLAN . This is a read only attribute
This attribute is named `gatewayID` in VSD API.
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var readonly
Get readonly value.
Notes: Determines whether this entity is read only. Read only objects cannot be modified or deleted.
var restricted
Get restricted value.
Notes: Determines whether this entity can be used in associations with other properties.
var status
Get status value.
Notes: Status of the VLAN.
var template_id
Get template_id value.
Notes: The ID of the template that this Port was created from
This attribute is named `templateID` in VSD API.
var use_user_mnemonic
Get use_user_mnemonic value.
Notes: determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
var user_mnemonic
Get user_mnemonic value.
Notes: user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
var value
Get value value.
Notes: value of VLAN
var vport_id
Get vport_id value.
Notes: The Vport associated with this VLAN . This is a read only attribute
This attribute is named `vportID` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VLAN instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vlan = NUVLAN(id=u'xxxx-xxx-xxx-xxx', name=u'VLAN') >>> vlan = NUVLAN(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VLAN instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vlan = NUVLAN(id=u'xxxx-xxx-xxx-xxx', name=u'VLAN')
>>> vlan = NUVLAN(data=my_dict)
"""
super(NUVLAN, self).__init__()
# Read/Write Attributes
self._value = None
self._last_updated_by = None
self._gateway_id = None
self._readonly = None
self._template_id = None
self._permitted_action = None
self._description = None
self._restricted = None
self._entity_scope = None
self._vport_id = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="value", remote_name="value", attribute_type=int, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway_id", remote_name="gatewayID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="readonly", remote_name="readonly", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="restricted", remote_name="restricted", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="vport_id", remote_name="vportID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVLANTemplate
Represents a VLANTemplate in the VSD
Notes: Represents VLAN Template under a Port Template object.
class NUVLANTemplate(NURESTObject):
""" Represents a VLANTemplate in the VSD
Notes:
Represents VLAN Template under a Port Template object.
"""
__rest_name__ = "vlantemplate"
__resource_name__ = "vlantemplates"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VLANTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vlantemplate = NUVLANTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'VLANTemplate')
>>> vlantemplate = NUVLANTemplate(data=my_dict)
"""
super(NUVLANTemplate, self).__init__()
# Read/Write Attributes
self._value = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._associated_egress_qos_policy_id = None
self._external_id = None
self.expose_attribute(local_name="value", remote_name="value", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def value(self):
""" Get value value.
Notes:
value of VLAN
"""
return self._value
@value.setter
def value(self, value):
""" Set value value.
Notes:
value of VLAN
"""
self._value = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUVLANTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var value
Get value value.
Notes: value of VLAN
Methods
def __init__(
self, **kwargs)
Initializes a VLANTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vlantemplate = NUVLANTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'VLANTemplate') >>> vlantemplate = NUVLANTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VLANTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vlantemplate = NUVLANTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'VLANTemplate')
>>> vlantemplate = NUVLANTemplate(data=my_dict)
"""
super(NUVLANTemplate, self).__init__()
# Read/Write Attributes
self._value = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._associated_egress_qos_policy_id = None
self._external_id = None
self.expose_attribute(local_name="value", remote_name="value", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVM
Represents a VM in the VSD
Notes: Read only API that can retrieve the VMs associated with a domain, zone or subnet for mediation created VM's for REST created VM's you need to set the additional proxy user header in http request : X-Nuage-ProxyUservalue of the header has to be either :1) enterpriseName@UserName (example : Alcatel Lucent@bob), or 2) external ID of user in VSD, typically is UUID generally decided by the CMS tool in questionUser needs to have CMS privileges to use proxy user header.
class NUVM(NURESTObject):
""" Represents a VM in the VSD
Notes:
Read only API that can retrieve the VMs associated with a domain, zone or subnet for mediation created VM's for REST created VM's you need to set the additional proxy user header in http request : X-Nuage-ProxyUservalue of the header has to be either :1) enterpriseName@UserName (example : Alcatel Lucent@bob), or 2) external ID of user in VSD, typically is UUID generally decided by the CMS tool in questionUser needs to have CMS privileges to use proxy user header.
"""
__rest_name__ = "vm"
__resource_name__ = "vms"
## Constants
CONST_REASON_TYPE_SHUTDOWN_UNKNOWN = "SHUTDOWN_UNKNOWN"
CONST_REASON_TYPE_CRASHED_UNKNOWN = "CRASHED_UNKNOWN"
CONST_REASON_TYPE_PAUSED_IOERROR = "PAUSED_IOERROR"
CONST_STATUS_SHUTDOWN = "SHUTDOWN"
CONST_REASON_TYPE_SHUTDOWN_LAST = "SHUTDOWN_LAST"
CONST_STATUS_DELETE_PENDING = "DELETE_PENDING"
CONST_REASON_TYPE_RUNNING_UNKNOWN = "RUNNING_UNKNOWN"
CONST_STATUS_RUNNING = "RUNNING"
CONST_REASON_TYPE_RUNNING_LAST = "RUNNING_LAST"
CONST_REASON_TYPE_RUNNING_UNPAUSED = "RUNNING_UNPAUSED"
CONST_REASON_TYPE_PAUSED_FROM_SNAPSHOT = "PAUSED_FROM_SNAPSHOT"
CONST_REASON_TYPE_PAUSED_MIGRATION = "PAUSED_MIGRATION"
CONST_REASON_TYPE_RUNNING_BOOTED = "RUNNING_BOOTED"
CONST_REASON_TYPE_UNKNOWN = "UNKNOWN"
CONST_STATUS_UNREACHABLE = "UNREACHABLE"
CONST_STATUS_BLOCKED = "BLOCKED"
CONST_REASON_TYPE_SHUTOFF_DESTROYED = "SHUTOFF_DESTROYED"
CONST_REASON_TYPE_SHUTOFF_FROM_SNAPSHOT = "SHUTOFF_FROM_SNAPSHOT"
CONST_REASON_TYPE_SHUTOFF_UNKNOWN = "SHUTOFF_UNKNOWN"
CONST_STATUS_NOSTATE = "NOSTATE"
CONST_REASON_TYPE_PAUSED_DUMP = "PAUSED_DUMP"
CONST_REASON_TYPE_CRASHED_LAST = "CRASHED_LAST"
CONST_STATUS_CRASHED = "CRASHED"
CONST_REASON_TYPE_PAUSED_LAST = "PAUSED_LAST"
CONST_REASON_TYPE_BLOCKED_LAST = "BLOCKED_LAST"
CONST_REASON_TYPE_SHUTOFF_LAST = "SHUTOFF_LAST"
CONST_STATUS_SHUTOFF = "SHUTOFF"
CONST_REASON_TYPE_SHUTOFF_SHUTDOWN = "SHUTOFF_SHUTDOWN"
CONST_REASON_TYPE_NOSTATE_UNKNOWN = "NOSTATE_UNKNOWN"
CONST_REASON_TYPE_PAUSED_SAVE = "PAUSED_SAVE"
CONST_REASON_TYPE_RUNNING_FROM_SNAPSHOT = "RUNNING_FROM_SNAPSHOT"
CONST_STATUS_UNKNOWN = "UNKNOWN"
CONST_REASON_TYPE_PAUSED_UNKNOWN = "PAUSED_UNKNOWN"
CONST_REASON_TYPE_SHUTOFF_FAILED = "SHUTOFF_FAILED"
CONST_REASON_TYPE_SHUTOFF_SAVED = "SHUTOFF_SAVED"
CONST_REASON_TYPE_SHUTOFF_MIGRATED = "SHUTOFF_MIGRATED"
CONST_STATUS_LAST = "LAST"
CONST_REASON_TYPE_RUNNING_MIGRATED = "RUNNING_MIGRATED"
CONST_REASON_TYPE_RUNNING_SAVE_CANCELED = "RUNNING_SAVE_CANCELED"
CONST_REASON_TYPE_SHUTDOWN_USER = "SHUTDOWN_USER"
CONST_REASON_TYPE_RUNNING_MIGRATION_CANCELED = "RUNNING_MIGRATION_CANCELED"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_STATUS_PAUSED = "PAUSED"
CONST_STATUS_INIT = "INIT"
CONST_REASON_TYPE_BLOCKED_UNKNOWN = "BLOCKED_UNKNOWN"
CONST_REASON_TYPE_NOSTATE_LAST = "NOSTATE_LAST"
CONST_REASON_TYPE_RUNNING_RESTORED = "RUNNING_RESTORED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_REASON_TYPE_SHUTOFF_CRASHED = "SHUTOFF_CRASHED"
CONST_REASON_TYPE_PAUSED_USER = "PAUSED_USER"
CONST_DELETE_MODE_TIMER = "TIMER"
CONST_REASON_TYPE_PAUSED_WATCHDOG = "PAUSED_WATCHDOG"
CONST_REASON_TYPE_PAUSED_SHUTTING_DOWN = "PAUSED_SHUTTING_DOWN"
def __init__(self, **kwargs):
""" Initializes a VM instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vm = NUVM(id=u'xxxx-xxx-xxx-xxx', name=u'VM')
>>> vm = NUVM(data=my_dict)
"""
super(NUVM, self).__init__()
# Read/Write Attributes
self._l2_domain_ids = None
self._vrsid = None
self._uuid = None
self._name = None
self._last_updated_by = None
self._reason_type = None
self._delete_expiry = None
self._delete_mode = None
self._resync_info = None
self._site_identifier = None
self._interfaces = None
self._enterprise_id = None
self._enterprise_name = None
self._entity_scope = None
self._domain_ids = None
self._zone_ids = None
self._app_name = None
self._orchestration_id = None
self._user_id = None
self._user_name = None
self._status = None
self._subnet_ids = None
self._external_id = None
self._hypervisor_ip = None
self.expose_attribute(local_name="l2_domain_ids", remote_name="l2DomainIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrsid", remote_name="VRSID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uuid", remote_name="UUID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reason_type", remote_name="reasonType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BLOCKED_LAST', u'BLOCKED_UNKNOWN', u'CRASHED_LAST', u'CRASHED_UNKNOWN', u'NOSTATE_LAST', u'NOSTATE_UNKNOWN', u'PAUSED_DUMP', u'PAUSED_FROM_SNAPSHOT', u'PAUSED_IOERROR', u'PAUSED_LAST', u'PAUSED_MIGRATION', u'PAUSED_SAVE', u'PAUSED_SHUTTING_DOWN', u'PAUSED_UNKNOWN', u'PAUSED_USER', u'PAUSED_WATCHDOG', u'RUNNING_BOOTED', u'RUNNING_FROM_SNAPSHOT', u'RUNNING_LAST', u'RUNNING_MIGRATED', u'RUNNING_MIGRATION_CANCELED', u'RUNNING_RESTORED', u'RUNNING_SAVE_CANCELED', u'RUNNING_UNKNOWN', u'RUNNING_UNPAUSED', u'SHUTDOWN_LAST', u'SHUTDOWN_UNKNOWN', u'SHUTDOWN_USER', u'SHUTOFF_CRASHED', u'SHUTOFF_DESTROYED', u'SHUTOFF_FAILED', u'SHUTOFF_FROM_SNAPSHOT', u'SHUTOFF_LAST', u'SHUTOFF_MIGRATED', u'SHUTOFF_SAVED', u'SHUTOFF_SHUTDOWN', u'SHUTOFF_UNKNOWN', u'UNKNOWN'])
self.expose_attribute(local_name="delete_expiry", remote_name="deleteExpiry", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="delete_mode", remote_name="deleteMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'TIMER'])
self.expose_attribute(local_name="resync_info", remote_name="resyncInfo", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_identifier", remote_name="siteIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="interfaces", remote_name="interfaces", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_name", remote_name="enterpriseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_ids", remote_name="domainIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_ids", remote_name="zoneIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="app_name", remote_name="appName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="orchestration_id", remote_name="orchestrationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_id", remote_name="userID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'BLOCKED', u'CRASHED', u'DELETE_PENDING', u'INIT', u'LAST', u'NOSTATE', u'PAUSED', u'RUNNING', u'SHUTDOWN', u'SHUTOFF', u'UNKNOWN', u'UNREACHABLE'])
self.expose_attribute(local_name="subnet_ids", remote_name="subnetIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="hypervisor_ip", remote_name="hypervisorIP", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.vm_resyncs = NUVMResyncsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def l2_domain_ids(self):
""" Get l2_domain_ids value.
Notes:
Array of IDs of the l2 domain that the VM is connected to
This attribute is named `l2DomainIDs` in VSD API.
"""
return self._l2_domain_ids
@l2_domain_ids.setter
def l2_domain_ids(self, value):
""" Set l2_domain_ids value.
Notes:
Array of IDs of the l2 domain that the VM is connected to
This attribute is named `l2DomainIDs` in VSD API.
"""
self._l2_domain_ids = value
@property
def vrsid(self):
""" Get vrsid value.
Notes:
Id of the VRS that this VM is attached to.
This attribute is named `VRSID` in VSD API.
"""
return self._vrsid
@vrsid.setter
def vrsid(self, value):
""" Set vrsid value.
Notes:
Id of the VRS that this VM is attached to.
This attribute is named `VRSID` in VSD API.
"""
self._vrsid = value
@property
def uuid(self):
""" Get uuid value.
Notes:
UUID of the VM
This attribute is named `UUID` in VSD API.
"""
return self._uuid
@uuid.setter
def uuid(self, value):
""" Set uuid value.
Notes:
UUID of the VM
This attribute is named `UUID` in VSD API.
"""
self._uuid = value
@property
def name(self):
""" Get name value.
Notes:
Name of the VM
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the VM
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def reason_type(self):
""" Get reason_type value.
Notes:
Reason of the event associated with the VM.
This attribute is named `reasonType` in VSD API.
"""
return self._reason_type
@reason_type.setter
def reason_type(self, value):
""" Set reason_type value.
Notes:
Reason of the event associated with the VM.
This attribute is named `reasonType` in VSD API.
"""
self._reason_type = value
@property
def delete_expiry(self):
""" Get delete_expiry value.
Notes:
reflects the VM Deletion expiry timer in secs , deleteMode needs to be non-null value for deleteExpiry to be taken in to effect. CMS created VM's will always have deleteMode set to TIMER
This attribute is named `deleteExpiry` in VSD API.
"""
return self._delete_expiry
@delete_expiry.setter
def delete_expiry(self, value):
""" Set delete_expiry value.
Notes:
reflects the VM Deletion expiry timer in secs , deleteMode needs to be non-null value for deleteExpiry to be taken in to effect. CMS created VM's will always have deleteMode set to TIMER
This attribute is named `deleteExpiry` in VSD API.
"""
self._delete_expiry = value
@property
def delete_mode(self):
""" Get delete_mode value.
Notes:
reflects the mode of VM Deletion - TIMER Possible values are TIMER, .
This attribute is named `deleteMode` in VSD API.
"""
return self._delete_mode
@delete_mode.setter
def delete_mode(self, value):
""" Set delete_mode value.
Notes:
reflects the mode of VM Deletion - TIMER Possible values are TIMER, .
This attribute is named `deleteMode` in VSD API.
"""
self._delete_mode = value
@property
def resync_info(self):
""" Get resync_info value.
Notes:
Information of the status of the resync operation of a VM
This attribute is named `resyncInfo` in VSD API.
"""
return self._resync_info
@resync_info.setter
def resync_info(self, value):
""" Set resync_info value.
Notes:
Information of the status of the resync operation of a VM
This attribute is named `resyncInfo` in VSD API.
"""
self._resync_info = value
@property
def site_identifier(self):
""" Get site_identifier value.
Notes:
This property specifies the site the VM belongs to, for Geo-redundancy.
This attribute is named `siteIdentifier` in VSD API.
"""
return self._site_identifier
@site_identifier.setter
def site_identifier(self, value):
""" Set site_identifier value.
Notes:
This property specifies the site the VM belongs to, for Geo-redundancy.
This attribute is named `siteIdentifier` in VSD API.
"""
self._site_identifier = value
@property
def interfaces(self):
""" Get interfaces value.
Notes:
List of VM interfaces associated with the VM
"""
return self._interfaces
@interfaces.setter
def interfaces(self, value):
""" Set interfaces value.
Notes:
List of VM interfaces associated with the VM
"""
self._interfaces = value
@property
def enterprise_id(self):
""" Get enterprise_id value.
Notes:
ID of the enterprise that this VM belongs to
This attribute is named `enterpriseID` in VSD API.
"""
return self._enterprise_id
@enterprise_id.setter
def enterprise_id(self, value):
""" Set enterprise_id value.
Notes:
ID of the enterprise that this VM belongs to
This attribute is named `enterpriseID` in VSD API.
"""
self._enterprise_id = value
@property
def enterprise_name(self):
""" Get enterprise_name value.
Notes:
Name of the enterprise that this VM belongs to
This attribute is named `enterpriseName` in VSD API.
"""
return self._enterprise_name
@enterprise_name.setter
def enterprise_name(self, value):
""" Set enterprise_name value.
Notes:
Name of the enterprise that this VM belongs to
This attribute is named `enterpriseName` in VSD API.
"""
self._enterprise_name = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def domain_ids(self):
""" Get domain_ids value.
Notes:
Array of IDs of the domain that the VM is connected to
This attribute is named `domainIDs` in VSD API.
"""
return self._domain_ids
@domain_ids.setter
def domain_ids(self, value):
""" Set domain_ids value.
Notes:
Array of IDs of the domain that the VM is connected to
This attribute is named `domainIDs` in VSD API.
"""
self._domain_ids = value
@property
def zone_ids(self):
""" Get zone_ids value.
Notes:
Array of IDs of the zone that this VM is attached to
This attribute is named `zoneIDs` in VSD API.
"""
return self._zone_ids
@zone_ids.setter
def zone_ids(self, value):
""" Set zone_ids value.
Notes:
Array of IDs of the zone that this VM is attached to
This attribute is named `zoneIDs` in VSD API.
"""
self._zone_ids = value
@property
def app_name(self):
""" Get app_name value.
Notes:
Application name that this VM belongs to
This attribute is named `appName` in VSD API.
"""
return self._app_name
@app_name.setter
def app_name(self, value):
""" Set app_name value.
Notes:
Application name that this VM belongs to
This attribute is named `appName` in VSD API.
"""
self._app_name = value
@property
def orchestration_id(self):
""" Get orchestration_id value.
Notes:
Orchestration ID.
This attribute is named `orchestrationID` in VSD API.
"""
return self._orchestration_id
@orchestration_id.setter
def orchestration_id(self, value):
""" Set orchestration_id value.
Notes:
Orchestration ID.
This attribute is named `orchestrationID` in VSD API.
"""
self._orchestration_id = value
@property
def user_id(self):
""" Get user_id value.
Notes:
ID of the user that created this VM
This attribute is named `userID` in VSD API.
"""
return self._user_id
@user_id.setter
def user_id(self, value):
""" Set user_id value.
Notes:
ID of the user that created this VM
This attribute is named `userID` in VSD API.
"""
self._user_id = value
@property
def user_name(self):
""" Get user_name value.
Notes:
Username of the user that created this VM
This attribute is named `userName` in VSD API.
"""
return self._user_name
@user_name.setter
def user_name(self, value):
""" Set user_name value.
Notes:
Username of the user that created this VM
This attribute is named `userName` in VSD API.
"""
self._user_name = value
@property
def status(self):
""" Get status value.
Notes:
Status of the VM.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Status of the VM.
"""
self._status = value
@property
def subnet_ids(self):
""" Get subnet_ids value.
Notes:
Array of IDs of the subnets that the VM is connected to
This attribute is named `subnetIDs` in VSD API.
"""
return self._subnet_ids
@subnet_ids.setter
def subnet_ids(self, value):
""" Set subnet_ids value.
Notes:
Array of IDs of the subnets that the VM is connected to
This attribute is named `subnetIDs` in VSD API.
"""
self._subnet_ids = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def hypervisor_ip(self):
""" Get hypervisor_ip value.
Notes:
IP address of the hypervisor that this VM is currently running in
This attribute is named `hypervisorIP` in VSD API.
"""
return self._hypervisor_ip
@hypervisor_ip.setter
def hypervisor_ip(self, value):
""" Set hypervisor_ip value.
Notes:
IP address of the hypervisor that this VM is currently running in
This attribute is named `hypervisorIP` in VSD API.
"""
self._hypervisor_ip = value
Ancestors (in MRO)
- NUVM
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_DELETE_MODE_TIMER
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_REASON_TYPE_BLOCKED_LAST
var CONST_REASON_TYPE_BLOCKED_UNKNOWN
var CONST_REASON_TYPE_CRASHED_LAST
var CONST_REASON_TYPE_CRASHED_UNKNOWN
var CONST_REASON_TYPE_NOSTATE_LAST
var CONST_REASON_TYPE_NOSTATE_UNKNOWN
var CONST_REASON_TYPE_PAUSED_DUMP
var CONST_REASON_TYPE_PAUSED_FROM_SNAPSHOT
var CONST_REASON_TYPE_PAUSED_IOERROR
var CONST_REASON_TYPE_PAUSED_LAST
var CONST_REASON_TYPE_PAUSED_MIGRATION
var CONST_REASON_TYPE_PAUSED_SAVE
var CONST_REASON_TYPE_PAUSED_SHUTTING_DOWN
var CONST_REASON_TYPE_PAUSED_UNKNOWN
var CONST_REASON_TYPE_PAUSED_USER
var CONST_REASON_TYPE_PAUSED_WATCHDOG
var CONST_REASON_TYPE_RUNNING_BOOTED
var CONST_REASON_TYPE_RUNNING_FROM_SNAPSHOT
var CONST_REASON_TYPE_RUNNING_LAST
var CONST_REASON_TYPE_RUNNING_MIGRATED
var CONST_REASON_TYPE_RUNNING_MIGRATION_CANCELED
var CONST_REASON_TYPE_RUNNING_RESTORED
var CONST_REASON_TYPE_RUNNING_SAVE_CANCELED
var CONST_REASON_TYPE_RUNNING_UNKNOWN
var CONST_REASON_TYPE_RUNNING_UNPAUSED
var CONST_REASON_TYPE_SHUTDOWN_LAST
var CONST_REASON_TYPE_SHUTDOWN_UNKNOWN
var CONST_REASON_TYPE_SHUTDOWN_USER
var CONST_REASON_TYPE_SHUTOFF_CRASHED
var CONST_REASON_TYPE_SHUTOFF_DESTROYED
var CONST_REASON_TYPE_SHUTOFF_FAILED
var CONST_REASON_TYPE_SHUTOFF_FROM_SNAPSHOT
var CONST_REASON_TYPE_SHUTOFF_LAST
var CONST_REASON_TYPE_SHUTOFF_MIGRATED
var CONST_REASON_TYPE_SHUTOFF_SAVED
var CONST_REASON_TYPE_SHUTOFF_SHUTDOWN
var CONST_REASON_TYPE_SHUTOFF_UNKNOWN
var CONST_REASON_TYPE_UNKNOWN
var CONST_STATUS_BLOCKED
var CONST_STATUS_CRASHED
var CONST_STATUS_DELETE_PENDING
var CONST_STATUS_INIT
var CONST_STATUS_LAST
var CONST_STATUS_NOSTATE
var CONST_STATUS_PAUSED
var CONST_STATUS_RUNNING
var CONST_STATUS_SHUTDOWN
var CONST_STATUS_SHUTOFF
var CONST_STATUS_UNKNOWN
var CONST_STATUS_UNREACHABLE
var resource_name
var rest_name
Instance variables
var alarms
var app_name
Get app_name value.
Notes: Application name that this VM belongs to
This attribute is named `appName` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var delete_expiry
Get delete_expiry value.
Notes: reflects the VM Deletion expiry timer in secs , deleteMode needs to be non-null value for deleteExpiry to be taken in to effect. CMS created VM's will always have deleteMode set to TIMER
This attribute is named `deleteExpiry` in VSD API.
var delete_mode
Get delete_mode value.
Notes: reflects the mode of VM Deletion - TIMER Possible values are TIMER, .
This attribute is named `deleteMode` in VSD API.
var domain_ids
Get domain_ids value.
Notes: Array of IDs of the domain that the VM is connected to
This attribute is named `domainIDs` in VSD API.
var enterprise_id
Get enterprise_id value.
Notes: ID of the enterprise that this VM belongs to
This attribute is named `enterpriseID` in VSD API.
var enterprise_name
Get enterprise_name value.
Notes: Name of the enterprise that this VM belongs to
This attribute is named `enterpriseName` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var hypervisor_ip
Get hypervisor_ip value.
Notes: IP address of the hypervisor that this VM is currently running in
This attribute is named `hypervisorIP` in VSD API.
var id
Get object id
var interfaces
Get interfaces value.
Notes: List of VM interfaces associated with the VM
var l2_domain_ids
Get l2_domain_ids value.
Notes: Array of IDs of the l2 domain that the VM is connected to
This attribute is named `l2DomainIDs` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the VM
var orchestration_id
Get orchestration_id value.
Notes: Orchestration ID.
This attribute is named `orchestrationID` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var reason_type
Get reason_type value.
Notes: Reason of the event associated with the VM.
This attribute is named `reasonType` in VSD API.
var resync_info
Get resync_info value.
Notes: Information of the status of the resync operation of a VM
This attribute is named `resyncInfo` in VSD API.
var site_identifier
Get site_identifier value.
Notes: This property specifies the site the VM belongs to, for Geo-redundancy.
This attribute is named `siteIdentifier` in VSD API.
var status
Get status value.
Notes: Status of the VM.
var subnet_ids
Get subnet_ids value.
Notes: Array of IDs of the subnets that the VM is connected to
This attribute is named `subnetIDs` in VSD API.
var user_id
Get user_id value.
Notes: ID of the user that created this VM
This attribute is named `userID` in VSD API.
var user_name
Get user_name value.
Notes: Username of the user that created this VM
This attribute is named `userName` in VSD API.
var uuid
Get uuid value.
Notes: UUID of the VM
This attribute is named `UUID` in VSD API.
var vm_interfaces
var vm_resyncs
var vrsid
Get vrsid value.
Notes: Id of the VRS that this VM is attached to.
This attribute is named `VRSID` in VSD API.
var vrss
var zone_ids
Get zone_ids value.
Notes: Array of IDs of the zone that this VM is attached to
This attribute is named `zoneIDs` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VM instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vm = NUVM(id=u'xxxx-xxx-xxx-xxx', name=u'VM') >>> vm = NUVM(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VM instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vm = NUVM(id=u'xxxx-xxx-xxx-xxx', name=u'VM')
>>> vm = NUVM(data=my_dict)
"""
super(NUVM, self).__init__()
# Read/Write Attributes
self._l2_domain_ids = None
self._vrsid = None
self._uuid = None
self._name = None
self._last_updated_by = None
self._reason_type = None
self._delete_expiry = None
self._delete_mode = None
self._resync_info = None
self._site_identifier = None
self._interfaces = None
self._enterprise_id = None
self._enterprise_name = None
self._entity_scope = None
self._domain_ids = None
self._zone_ids = None
self._app_name = None
self._orchestration_id = None
self._user_id = None
self._user_name = None
self._status = None
self._subnet_ids = None
self._external_id = None
self._hypervisor_ip = None
self.expose_attribute(local_name="l2_domain_ids", remote_name="l2DomainIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="vrsid", remote_name="VRSID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="uuid", remote_name="UUID", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="reason_type", remote_name="reasonType", attribute_type=str, is_required=False, is_unique=False, choices=[u'BLOCKED_LAST', u'BLOCKED_UNKNOWN', u'CRASHED_LAST', u'CRASHED_UNKNOWN', u'NOSTATE_LAST', u'NOSTATE_UNKNOWN', u'PAUSED_DUMP', u'PAUSED_FROM_SNAPSHOT', u'PAUSED_IOERROR', u'PAUSED_LAST', u'PAUSED_MIGRATION', u'PAUSED_SAVE', u'PAUSED_SHUTTING_DOWN', u'PAUSED_UNKNOWN', u'PAUSED_USER', u'PAUSED_WATCHDOG', u'RUNNING_BOOTED', u'RUNNING_FROM_SNAPSHOT', u'RUNNING_LAST', u'RUNNING_MIGRATED', u'RUNNING_MIGRATION_CANCELED', u'RUNNING_RESTORED', u'RUNNING_SAVE_CANCELED', u'RUNNING_UNKNOWN', u'RUNNING_UNPAUSED', u'SHUTDOWN_LAST', u'SHUTDOWN_UNKNOWN', u'SHUTDOWN_USER', u'SHUTOFF_CRASHED', u'SHUTOFF_DESTROYED', u'SHUTOFF_FAILED', u'SHUTOFF_FROM_SNAPSHOT', u'SHUTOFF_LAST', u'SHUTOFF_MIGRATED', u'SHUTOFF_SAVED', u'SHUTOFF_SHUTDOWN', u'SHUTOFF_UNKNOWN', u'UNKNOWN'])
self.expose_attribute(local_name="delete_expiry", remote_name="deleteExpiry", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="delete_mode", remote_name="deleteMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'TIMER'])
self.expose_attribute(local_name="resync_info", remote_name="resyncInfo", attribute_type=dict, is_required=False, is_unique=False)
self.expose_attribute(local_name="site_identifier", remote_name="siteIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="interfaces", remote_name="interfaces", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_id", remote_name="enterpriseID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_name", remote_name="enterpriseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_ids", remote_name="domainIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_ids", remote_name="zoneIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="app_name", remote_name="appName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="orchestration_id", remote_name="orchestrationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_id", remote_name="userID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_name", remote_name="userName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'BLOCKED', u'CRASHED', u'DELETE_PENDING', u'INIT', u'LAST', u'NOSTATE', u'PAUSED', u'RUNNING', u'SHUTDOWN', u'SHUTOFF', u'UNKNOWN', u'UNREACHABLE'])
self.expose_attribute(local_name="subnet_ids", remote_name="subnetIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="hypervisor_ip", remote_name="hypervisorIP", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.vm_resyncs = NUVMResyncsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVMInterface
Represents a VMInterface in the VSD
Notes: Read only API that can retrieve the VM interface associated with a domain, zone or subnet for mediation created VM's for REST created VM interfaces you need to set the additional proxy header in http request : X-Nuage-ProxyUservalue of the header has to be either :1) enterpriseName@UserName (example :bob@Alcatel Lucent), or 2) external ID of user in VSD, typically is UUID generally decided by the CMS tool in questionUser needs to have CMS privileges to use proxy user header.
class NUVMInterface(NURESTObject):
""" Represents a VMInterface in the VSD
Notes:
Read only API that can retrieve the VM interface associated with a domain, zone or subnet for mediation created VM's for REST created VM interfaces you need to set the additional proxy header in http request : X-Nuage-ProxyUservalue of the header has to be either :1) enterpriseName@UserName (example :bob@Alcatel Lucent), or 2) external ID of user in VSD, typically is UUID generally decided by the CMS tool in questionUser needs to have CMS privileges to use proxy user header.
"""
__rest_name__ = "vminterface"
__resource_name__ = "vminterfaces"
## Constants
CONST_ATTACHED_NETWORK_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ATTACHED_NETWORK_TYPE_SUBNET = "SUBNET"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VMInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vminterface = NUVMInterface(id=u'xxxx-xxx-xxx-xxx', name=u'VMInterface')
>>> vminterface = NUVMInterface(data=my_dict)
"""
super(NUVMInterface, self).__init__()
# Read/Write Attributes
self._mac = None
self._vmuuid = None
self._ip_address = None
self._vport_id = None
self._vport_name = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._netmask = None
self._network_name = None
self._tier_id = None
self._entity_scope = None
self._policy_decision_id = None
self._domain_id = None
self._domain_name = None
self._zone_id = None
self._zone_name = None
self._associated_floating_ip_address = None
self._attached_network_id = None
self._attached_network_type = None
self._multi_nic_vport_name = None
self._external_id = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vmuuid", remote_name="VMUUID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="IPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_id", remote_name="VPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tier_id", remote_name="tierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_decision_id", remote_name="policyDecisionID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_name", remote_name="zoneName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_address", remote_name="associatedFloatingIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_id", remote_name="attachedNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'L2DOMAIN', u'SUBNET'])
self.expose_attribute(local_name="multi_nic_vport_name", remote_name="multiNICVPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_decisions = NUPolicyDecisionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def mac(self):
""" Get mac value.
Notes:
MAC address of the interface
This attribute is named `MAC` in VSD API.
"""
return self._mac
@mac.setter
def mac(self, value):
""" Set mac value.
Notes:
MAC address of the interface
This attribute is named `MAC` in VSD API.
"""
self._mac = value
@property
def vmuuid(self):
""" Get vmuuid value.
Notes:
UUID of the associated virtual machine
This attribute is named `VMUUID` in VSD API.
"""
return self._vmuuid
@vmuuid.setter
def vmuuid(self, value):
""" Set vmuuid value.
Notes:
UUID of the associated virtual machine
This attribute is named `VMUUID` in VSD API.
"""
self._vmuuid = value
@property
def ip_address(self):
""" Get ip_address value.
Notes:
IP address of the interface
This attribute is named `IPAddress` in VSD API.
"""
return self._ip_address
@ip_address.setter
def ip_address(self, value):
""" Set ip_address value.
Notes:
IP address of the interface
This attribute is named `IPAddress` in VSD API.
"""
self._ip_address = value
@property
def vport_id(self):
""" Get vport_id value.
Notes:
ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
"""
return self._vport_id
@vport_id.setter
def vport_id(self, value):
""" Set vport_id value.
Notes:
ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
"""
self._vport_id = value
@property
def vport_name(self):
""" Get vport_name value.
Notes:
Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
"""
return self._vport_name
@vport_name.setter
def vport_name(self, value):
""" Set vport_name value.
Notes:
Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
"""
self._vport_name = value
@property
def name(self):
""" Get name value.
Notes:
Device name associated with this interface
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Device name associated with this interface
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def gateway(self):
""" Get gateway value.
Notes:
Gateway of the subnet that the VM is connected to
"""
return self._gateway
@gateway.setter
def gateway(self, value):
""" Set gateway value.
Notes:
Gateway of the subnet that the VM is connected to
"""
self._gateway = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet that the VM is attached to
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet that the VM is attached to
"""
self._netmask = value
@property
def network_name(self):
""" Get network_name value.
Notes:
Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
"""
return self._network_name
@network_name.setter
def network_name(self, value):
""" Set network_name value.
Notes:
Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
"""
self._network_name = value
@property
def tier_id(self):
""" Get tier_id value.
Notes:
ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
"""
return self._tier_id
@tier_id.setter
def tier_id(self, value):
""" Set tier_id value.
Notes:
ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
"""
self._tier_id = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_decision_id(self):
""" Get policy_decision_id value.
Notes:
The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
"""
return self._policy_decision_id
@policy_decision_id.setter
def policy_decision_id(self, value):
""" Set policy_decision_id value.
Notes:
The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
"""
self._policy_decision_id = value
@property
def domain_id(self):
""" Get domain_id value.
Notes:
ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
"""
return self._domain_id
@domain_id.setter
def domain_id(self, value):
""" Set domain_id value.
Notes:
ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
"""
self._domain_id = value
@property
def domain_name(self):
""" Get domain_name value.
Notes:
Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
"""
return self._domain_name
@domain_name.setter
def domain_name(self, value):
""" Set domain_name value.
Notes:
Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
"""
self._domain_name = value
@property
def zone_id(self):
""" Get zone_id value.
Notes:
ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
"""
return self._zone_id
@zone_id.setter
def zone_id(self, value):
""" Set zone_id value.
Notes:
ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
"""
self._zone_id = value
@property
def zone_name(self):
""" Get zone_name value.
Notes:
Name of the zone that the VM is attached to
This attribute is named `zoneName` in VSD API.
"""
return self._zone_name
@zone_name.setter
def zone_name(self, value):
""" Set zone_name value.
Notes:
Name of the zone that the VM is attached to
This attribute is named `zoneName` in VSD API.
"""
self._zone_name = value
@property
def associated_floating_ip_address(self):
""" Get associated_floating_ip_address value.
Notes:
Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
"""
return self._associated_floating_ip_address
@associated_floating_ip_address.setter
def associated_floating_ip_address(self, value):
""" Set associated_floating_ip_address value.
Notes:
Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
"""
self._associated_floating_ip_address = value
@property
def attached_network_id(self):
""" Get attached_network_id value.
Notes:
ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
"""
return self._attached_network_id
@attached_network_id.setter
def attached_network_id(self, value):
""" Set attached_network_id value.
Notes:
ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
"""
self._attached_network_id = value
@property
def attached_network_type(self):
""" Get attached_network_type value.
Notes:
l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
"""
return self._attached_network_type
@attached_network_type.setter
def attached_network_type(self, value):
""" Set attached_network_type value.
Notes:
l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
"""
self._attached_network_type = value
@property
def multi_nic_vport_name(self):
""" Get multi_nic_vport_name value.
Notes:
Name of the Multi NIC VPort associated with this VM Interface
This attribute is named `multiNICVPortName` in VSD API.
"""
return self._multi_nic_vport_name
@multi_nic_vport_name.setter
def multi_nic_vport_name(self, value):
""" Set multi_nic_vport_name value.
Notes:
Name of the Multi NIC VPort associated with this VM Interface
This attribute is named `multiNICVPortName` in VSD API.
"""
self._multi_nic_vport_name = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVMInterface
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ATTACHED_NETWORK_TYPE_L2DOMAIN
var CONST_ATTACHED_NETWORK_TYPE_SUBNET
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_floating_ip_address
Get associated_floating_ip_address value.
Notes: Floating Ip Address of this network interface eg: 10.1.2.1
This attribute is named `associatedFloatingIPAddress` in VSD API.
var attached_network_id
Get attached_network_id value.
Notes: ID of the l2 domain or Subnet that the VM is attached to
This attribute is named `attachedNetworkID` in VSD API.
var attached_network_type
Get attached_network_type value.
Notes: l2 domain or Subnet that the interface is attached to
This attribute is named `attachedNetworkType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var dhcp_options
var domain_id
Get domain_id value.
Notes: ID of the domain that the VM is attached to
This attribute is named `domainID` in VSD API.
var domain_name
Get domain_name value.
Notes: Name of the domain that the VM is attached to
This attribute is named `domainName` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var gateway
Get gateway value.
Notes: Gateway of the subnet that the VM is connected to
var global_metadatas
var id
Get object id
var ip_address
Get ip_address value.
Notes: IP address of the interface
This attribute is named `IPAddress` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var mac
Get mac value.
Notes: MAC address of the interface
This attribute is named `MAC` in VSD API.
var metadatas
var multi_cast_channel_maps
var multi_nic_vport_name
Get multi_nic_vport_name value.
Notes: Name of the Multi NIC VPort associated with this VM Interface
This attribute is named `multiNICVPortName` in VSD API.
var name
Get name value.
Notes: Device name associated with this interface
var netmask
Get netmask value.
Notes: Netmask of the subnet that the VM is attached to
var network_name
Get network_name value.
Notes: Name of the network that the VM is attached to
This attribute is named `networkName` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var policy_decision_id
Get policy_decision_id value.
Notes: The policy decision ID for this particular interface
This attribute is named `policyDecisionID` in VSD API.
var policy_decisions
var policy_groups
var redirection_targets
var static_routes
var statistics
var tcas
var tier_id
Get tier_id value.
Notes: ID of the tier that the interface is attached to.
This attribute is named `tierID` in VSD API.
var vmuuid
Get vmuuid value.
Notes: UUID of the associated virtual machine
This attribute is named `VMUUID` in VSD API.
var vport_id
Get vport_id value.
Notes: ID of the vport that the interface is attached to
This attribute is named `VPortID` in VSD API.
var vport_name
Get vport_name value.
Notes: Name of the vport that the VM is attached to
This attribute is named `VPortName` in VSD API.
var zone_id
Get zone_id value.
Notes: ID of the zone that the interface is attached to
This attribute is named `zoneID` in VSD API.
var zone_name
Get zone_name value.
Notes: Name of the zone that the VM is attached to
This attribute is named `zoneName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VMInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vminterface = NUVMInterface(id=u'xxxx-xxx-xxx-xxx', name=u'VMInterface') >>> vminterface = NUVMInterface(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VMInterface instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vminterface = NUVMInterface(id=u'xxxx-xxx-xxx-xxx', name=u'VMInterface')
>>> vminterface = NUVMInterface(data=my_dict)
"""
super(NUVMInterface, self).__init__()
# Read/Write Attributes
self._mac = None
self._vmuuid = None
self._ip_address = None
self._vport_id = None
self._vport_name = None
self._name = None
self._last_updated_by = None
self._gateway = None
self._netmask = None
self._network_name = None
self._tier_id = None
self._entity_scope = None
self._policy_decision_id = None
self._domain_id = None
self._domain_name = None
self._zone_id = None
self._zone_name = None
self._associated_floating_ip_address = None
self._attached_network_id = None
self._attached_network_type = None
self._multi_nic_vport_name = None
self._external_id = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vmuuid", remote_name="VMUUID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="ip_address", remote_name="IPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_id", remote_name="VPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="gateway", remote_name="gateway", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tier_id", remote_name="tierID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_decision_id", remote_name="policyDecisionID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_name", remote_name="zoneName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_floating_ip_address", remote_name="associatedFloatingIPAddress", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_id", remote_name="attachedNetworkID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False, choices=[u'L2DOMAIN', u'SUBNET'])
self.expose_attribute(local_name="multi_nic_vport_name", remote_name="multiNICVPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_decisions = NUPolicyDecisionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.static_routes = NUStaticRoutesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_cast_channel_maps = NUMultiCastChannelMapsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVMResync
Represents a VMResync in the VSD
Notes: Provide information about the state of a VM resync request.
class NUVMResync(NURESTObject):
""" Represents a VMResync in the VSD
Notes:
Provide information about the state of a VM resync request.
"""
__rest_name__ = "resync"
__resource_name__ = "resync"
## Constants
CONST_STATUS_IN_PROGRESS = "IN_PROGRESS"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_STATUS_SUCCESS = "SUCCESS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VMResync instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vmresync = NUVMResync(id=u'xxxx-xxx-xxx-xxx', name=u'VMResync')
>>> vmresync = NUVMResync(data=my_dict)
"""
super(NUVMResync, self).__init__()
# Read/Write Attributes
self._last_request_timestamp = None
self._last_time_resync_initiated = None
self._last_updated_by = None
self._entity_scope = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="last_request_timestamp", remote_name="lastRequestTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_time_resync_initiated", remote_name="lastTimeResyncInitiated", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'IN_PROGRESS', u'SUCCESS'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_request_timestamp(self):
""" Get last_request_timestamp value.
Notes:
Time of the last timestamp received
This attribute is named `lastRequestTimestamp` in VSD API.
"""
return self._last_request_timestamp
@last_request_timestamp.setter
def last_request_timestamp(self, value):
""" Set last_request_timestamp value.
Notes:
Time of the last timestamp received
This attribute is named `lastRequestTimestamp` in VSD API.
"""
self._last_request_timestamp = value
@property
def last_time_resync_initiated(self):
""" Get last_time_resync_initiated value.
Notes:
Time that the resync was initiated
This attribute is named `lastTimeResyncInitiated` in VSD API.
"""
return self._last_time_resync_initiated
@last_time_resync_initiated.setter
def last_time_resync_initiated(self, value):
""" Set last_time_resync_initiated value.
Notes:
Time that the resync was initiated
This attribute is named `lastTimeResyncInitiated` in VSD API.
"""
self._last_time_resync_initiated = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def status(self):
""" Get status value.
Notes:
Status of the resync
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Status of the resync
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVMResync
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_STATUS_IN_PROGRESS
var CONST_STATUS_SUCCESS
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_request_timestamp
Get last_request_timestamp value.
Notes: Time of the last timestamp received
This attribute is named `lastRequestTimestamp` in VSD API.
var last_time_resync_initiated
Get last_time_resync_initiated value.
Notes: Time that the resync was initiated
This attribute is named `lastTimeResyncInitiated` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var status
Get status value.
Notes: Status of the resync
Methods
def __init__(
self, **kwargs)
Initializes a VMResync instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vmresync = NUVMResync(id=u'xxxx-xxx-xxx-xxx', name=u'VMResync') >>> vmresync = NUVMResync(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VMResync instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vmresync = NUVMResync(id=u'xxxx-xxx-xxx-xxx', name=u'VMResync')
>>> vmresync = NUVMResync(data=my_dict)
"""
super(NUVMResync, self).__init__()
# Read/Write Attributes
self._last_request_timestamp = None
self._last_time_resync_initiated = None
self._last_updated_by = None
self._entity_scope = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="last_request_timestamp", remote_name="lastRequestTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_time_resync_initiated", remote_name="lastTimeResyncInitiated", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'IN_PROGRESS', u'SUCCESS'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVPNConnection
Represents a VPNConnection in the VSD
Notes: This is the definition of a VPN Connect which holds the PE service assocaition with a DOMAIN.
class NUVPNConnection(NURESTObject):
""" Represents a VPNConnection in the VSD
Notes:
This is the definition of a VPN Connect which holds the PE service assocaition with a DOMAIN.
"""
__rest_name__ = "vpnconnection"
__resource_name__ = "vpnconnections"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VPNConnection instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vpnconnection = NUVPNConnection(id=u'xxxx-xxx-xxx-xxx', name=u'VPNConnection')
>>> vpnconnection = NUVPNConnection(data=my_dict)
"""
super(NUVPNConnection, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._associated_wan_service_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_wan_service_id", remote_name="associatedWANServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the VPNConnect
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the VPNConnect
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
A description of the VPNConnect
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the VPNConnect
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_wan_service_id(self):
""" Get associated_wan_service_id value.
Notes:
Assosciated WAN Service
This attribute is named `associatedWANServiceID` in VSD API.
"""
return self._associated_wan_service_id
@associated_wan_service_id.setter
def associated_wan_service_id(self, value):
""" Set associated_wan_service_id value.
Notes:
Assosciated WAN Service
This attribute is named `associatedWANServiceID` in VSD API.
"""
self._associated_wan_service_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVPNConnection
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_wan_service_id
Get associated_wan_service_id value.
Notes: Assosciated WAN Service
This attribute is named `associatedWANServiceID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the VPNConnect
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the VPNConnect
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a VPNConnection instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vpnconnection = NUVPNConnection(id=u'xxxx-xxx-xxx-xxx', name=u'VPNConnection') >>> vpnconnection = NUVPNConnection(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VPNConnection instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vpnconnection = NUVPNConnection(id=u'xxxx-xxx-xxx-xxx', name=u'VPNConnection')
>>> vpnconnection = NUVPNConnection(data=my_dict)
"""
super(NUVPNConnection, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._associated_wan_service_id = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_wan_service_id", remote_name="associatedWANServiceID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVPort
Represents a VPort in the VSD
Notes: VPorts are a new level in the domain hierarchy, intended to provide more granular configuration than at subnet, and also support a split workflow, where the vPort is configured and associated with a VM port (or gateway port) before the port exists on the hypervisor or gateway.
class NUVPort(NURESTObject):
""" Represents a VPort in the VSD
Notes:
VPorts are a new level in the domain hierarchy, intended to provide more granular configuration than at subnet, and also support a split workflow, where the vPort is configured and associated with a VM port (or gateway port) before the port exists on the hypervisor or gateway.
"""
__rest_name__ = "vport"
__resource_name__ = "vports"
## Constants
CONST_SYSTEM_TYPE_NUAGE_2 = "NUAGE_2"
CONST_SYSTEM_TYPE_NUAGE_1 = "NUAGE_1"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ADDRESS_SPOOFING_DISABLED = "DISABLED"
CONST_ADDRESS_SPOOFING_INHERITED = "INHERITED"
CONST_TYPE_HOST = "HOST"
CONST_PEER_OPERATIONAL_STATE_INIT = "INIT"
CONST_ADDRESS_SPOOFING_ENABLED = "ENABLED"
CONST_SYSTEM_TYPE_SOFTWARE = "SOFTWARE"
CONST_OPERATIONAL_STATE_DOWN = "DOWN"
CONST_PEER_OPERATIONAL_STATE_DOWN = "DOWN"
CONST_OPERATIONAL_STATE_UP = "UP"
CONST_PEER_OPERATIONAL_STATE_UP = "UP"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_MULTICAST_INHERITED = "INHERITED"
CONST_SYSTEM_TYPE_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_SYSTEM_TYPE_HARDWARE = "HARDWARE"
CONST_TYPE_BRIDGE = "BRIDGE"
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_SYSTEM_TYPE_NUAGE_VRSG = "NUAGE_VRSG"
CONST_OPERATIONAL_STATE_INIT = "INIT"
CONST_TYPE_VM = "VM"
def __init__(self, **kwargs):
""" Initializes a VPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vport = NUVPort(id=u'xxxx-xxx-xxx-xxx', name=u'VPort')
>>> vport = NUVPort(data=my_dict)
"""
super(NUVPort, self).__init__()
# Read/Write Attributes
self._vlanid = None
self._name = None
self._has_attached_interfaces = None
self._last_updated_by = None
self._active = None
self._address_spoofing = None
self._peer_operational_state = None
self._description = None
self._entity_scope = None
self._domain_id = None
self._zone_id = None
self._operational_state = None
self._associated_floating_ip_id = None
self._associated_multicast_channel_map_id = None
self._associated_send_multicast_channel_map_id = None
self._multi_nic_vport_id = None
self._multicast = None
self._external_id = None
self._type = None
self._system_type = None
self.expose_attribute(local_name="vlanid", remote_name="VLANID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="has_attached_interfaces", remote_name="hasAttachedInterfaces", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_spoofing", remote_name="addressSpoofing", attribute_type=str, is_required=True, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="peer_operational_state", remote_name="peerOperationalState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOWN', u'INIT', u'UP'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="operational_state", remote_name="operationalState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOWN', u'INIT', u'UP'])
self.expose_attribute(local_name="associated_floating_ip_id", remote_name="associatedFloatingIPID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_send_multicast_channel_map_id", remote_name="associatedSendMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_nic_vport_id", remote_name="multiNICVPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'BRIDGE', u'HOST', u'VM'])
self.expose_attribute(local_name="system_type", remote_name="systemType", attribute_type=str, is_required=False, is_unique=False, choices=[u'HARDWARE', u'HARDWARE_VTEP', u'NUAGE_1', u'NUAGE_2', u'NUAGE_VRSG', u'SOFTWARE'])
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.aggregate_metadatas = NUAggregateMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.virtual_ips = NUVirtualIPsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vport_mirrors = NUVPortMirrorsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bridge_interfaces = NUBridgeInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vlanid(self):
""" Get vlanid value.
Notes:
associated Vlan of this vport - applicable for type host/bridge
This attribute is named `VLANID` in VSD API.
"""
return self._vlanid
@vlanid.setter
def vlanid(self, value):
""" Set vlanid value.
Notes:
associated Vlan of this vport - applicable for type host/bridge
This attribute is named `VLANID` in VSD API.
"""
self._vlanid = value
@property
def name(self):
""" Get name value.
Notes:
Name of the vport. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the vport. Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def has_attached_interfaces(self):
""" Get has_attached_interfaces value.
Notes:
Indicates that this vport has attached interfaces
This attribute is named `hasAttachedInterfaces` in VSD API.
"""
return self._has_attached_interfaces
@has_attached_interfaces.setter
def has_attached_interfaces(self, value):
""" Set has_attached_interfaces value.
Notes:
Indicates that this vport has attached interfaces
This attribute is named `hasAttachedInterfaces` in VSD API.
"""
self._has_attached_interfaces = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def active(self):
""" Get active value.
Notes:
Indicates if this vport is up or down
"""
return self._active
@active.setter
def active(self, value):
""" Set active value.
Notes:
Indicates if this vport is up or down
"""
self._active = value
@property
def address_spoofing(self):
""" Get address_spoofing value.
Notes:
Indicates if address spoofing is ENABLED/DISABLED/INHERITED for this vport Possible values are INHERITED, ENABLED, DISABLED, .
This attribute is named `addressSpoofing` in VSD API.
"""
return self._address_spoofing
@address_spoofing.setter
def address_spoofing(self, value):
""" Set address_spoofing value.
Notes:
Indicates if address spoofing is ENABLED/DISABLED/INHERITED for this vport Possible values are INHERITED, ENABLED, DISABLED, .
This attribute is named `addressSpoofing` in VSD API.
"""
self._address_spoofing = value
@property
def peer_operational_state(self):
""" Get peer_operational_state value.
Notes:
Operational State of the VPort - RUNNING/SHUTDOWN for peer in mc lag scenarios.
This attribute is named `peerOperationalState` in VSD API.
"""
return self._peer_operational_state
@peer_operational_state.setter
def peer_operational_state(self, value):
""" Set peer_operational_state value.
Notes:
Operational State of the VPort - RUNNING/SHUTDOWN for peer in mc lag scenarios.
This attribute is named `peerOperationalState` in VSD API.
"""
self._peer_operational_state = value
@property
def description(self):
""" Get description value.
Notes:
Description for this vport
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description for this vport
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def domain_id(self):
""" Get domain_id value.
Notes:
ID the Domain associated with the VPort
This attribute is named `domainID` in VSD API.
"""
return self._domain_id
@domain_id.setter
def domain_id(self, value):
""" Set domain_id value.
Notes:
ID the Domain associated with the VPort
This attribute is named `domainID` in VSD API.
"""
self._domain_id = value
@property
def zone_id(self):
""" Get zone_id value.
Notes:
ID the Zone associated with the VPort
This attribute is named `zoneID` in VSD API.
"""
return self._zone_id
@zone_id.setter
def zone_id(self, value):
""" Set zone_id value.
Notes:
ID the Zone associated with the VPort
This attribute is named `zoneID` in VSD API.
"""
self._zone_id = value
@property
def operational_state(self):
""" Get operational_state value.
Notes:
Operational State of the VPort - RUNNING/SHUTDOWN Possible values are INIT, UP, DOWN, .
This attribute is named `operationalState` in VSD API.
"""
return self._operational_state
@operational_state.setter
def operational_state(self, value):
""" Set operational_state value.
Notes:
Operational State of the VPort - RUNNING/SHUTDOWN Possible values are INIT, UP, DOWN, .
This attribute is named `operationalState` in VSD API.
"""
self._operational_state = value
@property
def associated_floating_ip_id(self):
""" Get associated_floating_ip_id value.
Notes:
Id of Floating IP address associated to this vport
This attribute is named `associatedFloatingIPID` in VSD API.
"""
return self._associated_floating_ip_id
@associated_floating_ip_id.setter
def associated_floating_ip_id(self, value):
""" Set associated_floating_ip_id value.
Notes:
Id of Floating IP address associated to this vport
This attribute is named `associatedFloatingIPID` in VSD API.
"""
self._associated_floating_ip_id = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the receive Multicast Channel Map this Vport is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the receive Multicast Channel Map this Vport is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def associated_send_multicast_channel_map_id(self):
""" Get associated_send_multicast_channel_map_id value.
Notes:
The ID of the send Multicast Channel Map this Vport is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedSendMulticastChannelMapID` in VSD API.
"""
return self._associated_send_multicast_channel_map_id
@associated_send_multicast_channel_map_id.setter
def associated_send_multicast_channel_map_id(self, value):
""" Set associated_send_multicast_channel_map_id value.
Notes:
The ID of the send Multicast Channel Map this Vport is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedSendMulticastChannelMapID` in VSD API.
"""
self._associated_send_multicast_channel_map_id = value
@property
def multi_nic_vport_id(self):
""" Get multi_nic_vport_id value.
Notes:
ID of the Multi NIC VPort associated with the VPort
This attribute is named `multiNICVPortID` in VSD API.
"""
return self._multi_nic_vport_id
@multi_nic_vport_id.setter
def multi_nic_vport_id(self, value):
""" Set multi_nic_vport_id value.
Notes:
ID of the Multi NIC VPort associated with the VPort
This attribute is named `multiNICVPortID` in VSD API.
"""
self._multi_nic_vport_id = value
@property
def multicast(self):
""" Get multicast value.
Notes:
Indicates multicast policy on Vport.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
Indicates multicast policy on Vport.
"""
self._multicast = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
Type of vport - possible values VM/HOST/BRIDGE Possible values are VM, HOST, BRIDGE, .
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
Type of vport - possible values VM/HOST/BRIDGE Possible values are VM, HOST, BRIDGE, .
"""
self._type = value
@property
def system_type(self):
""" Get system_type value.
Notes:
Indicates what system it is.
This attribute is named `systemType` in VSD API.
"""
return self._system_type
@system_type.setter
def system_type(self, value):
""" Set system_type value.
Notes:
Indicates what system it is.
This attribute is named `systemType` in VSD API.
"""
self._system_type = value
Ancestors (in MRO)
- NUVPort
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ADDRESS_SPOOFING_DISABLED
var CONST_ADDRESS_SPOOFING_ENABLED
var CONST_ADDRESS_SPOOFING_INHERITED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var CONST_OPERATIONAL_STATE_DOWN
var CONST_OPERATIONAL_STATE_INIT
var CONST_OPERATIONAL_STATE_UP
var CONST_PEER_OPERATIONAL_STATE_DOWN
var CONST_PEER_OPERATIONAL_STATE_INIT
var CONST_PEER_OPERATIONAL_STATE_UP
var CONST_SYSTEM_TYPE_HARDWARE
var CONST_SYSTEM_TYPE_HARDWARE_VTEP
var CONST_SYSTEM_TYPE_NUAGE_1
var CONST_SYSTEM_TYPE_NUAGE_2
var CONST_SYSTEM_TYPE_NUAGE_VRSG
var CONST_SYSTEM_TYPE_SOFTWARE
var CONST_TYPE_BRIDGE
var CONST_TYPE_HOST
var CONST_TYPE_VM
var resource_name
var rest_name
Instance variables
var active
Get active value.
Notes: Indicates if this vport is up or down
var address_spoofing
Get address_spoofing value.
Notes: Indicates if address spoofing is ENABLED/DISABLED/INHERITED for this vport Possible values are INHERITED, ENABLED, DISABLED, .
This attribute is named `addressSpoofing` in VSD API.
var aggregate_metadatas
var alarms
var associated_floating_ip_id
Get associated_floating_ip_id value.
Notes: Id of Floating IP address associated to this vport
This attribute is named `associatedFloatingIPID` in VSD API.
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the receive Multicast Channel Map this Vport is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
var associated_send_multicast_channel_map_id
Get associated_send_multicast_channel_map_id value.
Notes: The ID of the send Multicast Channel Map this Vport is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedSendMulticastChannelMapID` in VSD API.
var bridge_interfaces
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description for this vport
var dhcp_options
var domain_id
Get domain_id value.
Notes: ID the Domain associated with the VPort
This attribute is named `domainID` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var has_attached_interfaces
Get has_attached_interfaces value.
Notes: Indicates that this vport has attached interfaces
This attribute is named `hasAttachedInterfaces` in VSD API.
var host_interfaces
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var multi_nic_vport_id
Get multi_nic_vport_id value.
Notes: ID of the Multi NIC VPort associated with the VPort
This attribute is named `multiNICVPortID` in VSD API.
var multicast
Get multicast value.
Notes: Indicates multicast policy on Vport.
var name
Get name value.
Notes: Name of the vport. Valid characters are alphabets, numbers, space and hyphen( - ).
var operational_state
Get operational_state value.
Notes: Operational State of the VPort - RUNNING/SHUTDOWN Possible values are INIT, UP, DOWN, .
This attribute is named `operationalState` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var peer_operational_state
Get peer_operational_state value.
Notes: Operational State of the VPort - RUNNING/SHUTDOWN for peer in mc lag scenarios.
This attribute is named `peerOperationalState` in VSD API.
var policy_groups
var qoss
var redirection_targets
var statistics
var statistics_policies
var system_type
Get system_type value.
Notes: Indicates what system it is.
This attribute is named `systemType` in VSD API.
var tcas
var type
Get type value.
Notes: Type of vport - possible values VM/HOST/BRIDGE Possible values are VM, HOST, BRIDGE, .
var virtual_ips
var vlanid
Get vlanid value.
Notes: associated Vlan of this vport - applicable for type host/bridge
This attribute is named `VLANID` in VSD API.
var vm_interfaces
var vms
var vport_mirrors
var vrss
var zone_id
Get zone_id value.
Notes: ID the Zone associated with the VPort
This attribute is named `zoneID` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vport = NUVPort(id=u'xxxx-xxx-xxx-xxx', name=u'VPort') >>> vport = NUVPort(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vport = NUVPort(id=u'xxxx-xxx-xxx-xxx', name=u'VPort')
>>> vport = NUVPort(data=my_dict)
"""
super(NUVPort, self).__init__()
# Read/Write Attributes
self._vlanid = None
self._name = None
self._has_attached_interfaces = None
self._last_updated_by = None
self._active = None
self._address_spoofing = None
self._peer_operational_state = None
self._description = None
self._entity_scope = None
self._domain_id = None
self._zone_id = None
self._operational_state = None
self._associated_floating_ip_id = None
self._associated_multicast_channel_map_id = None
self._associated_send_multicast_channel_map_id = None
self._multi_nic_vport_id = None
self._multicast = None
self._external_id = None
self._type = None
self._system_type = None
self.expose_attribute(local_name="vlanid", remote_name="VLANID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="has_attached_interfaces", remote_name="hasAttachedInterfaces", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="active", remote_name="active", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="address_spoofing", remote_name="addressSpoofing", attribute_type=str, is_required=True, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="peer_operational_state", remote_name="peerOperationalState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOWN', u'INIT', u'UP'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_id", remote_name="domainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="zone_id", remote_name="zoneID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="operational_state", remote_name="operationalState", attribute_type=str, is_required=False, is_unique=False, choices=[u'DOWN', u'INIT', u'UP'])
self.expose_attribute(local_name="associated_floating_ip_id", remote_name="associatedFloatingIPID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_send_multicast_channel_map_id", remote_name="associatedSendMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multi_nic_vport_id", remote_name="multiNICVPortID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=True, is_unique=False, choices=[u'BRIDGE', u'HOST', u'VM'])
self.expose_attribute(local_name="system_type", remote_name="systemType", attribute_type=str, is_required=False, is_unique=False, choices=[u'HARDWARE', u'HARDWARE_VTEP', u'NUAGE_1', u'NUAGE_2', u'NUAGE_VRSG', u'SOFTWARE'])
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.redirection_targets = NURedirectionTargetsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.aggregate_metadatas = NUAggregateMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.virtual_ips = NUVirtualIPsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.policy_groups = NUPolicyGroupsFetcher.fetcher_with_object(parent_object=self, relationship="member")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.host_interfaces = NUHostInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vport_mirrors = NUVPortMirrorsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bridge_interfaces = NUBridgeInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVPortMirror
Represents a VPortMirror in the VSD
Notes: VPort Mirror represents the relationship between a vport and a mirror destination.
class NUVPortMirror(NURESTObject):
""" Represents a VPortMirror in the VSD
Notes:
VPort Mirror represents the relationship between a vport and a mirror destination.
"""
__rest_name__ = "vportmirror"
__resource_name__ = "vportmirrors"
## Constants
CONST_MIRROR_DIRECTION_BOTH = "BOTH"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_MIRROR_DIRECTION_INGRESS = "INGRESS"
CONST_MIRROR_DIRECTION_EGRESS = "EGRESS"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VPortMirror instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vportmirror = NUVPortMirror(id=u'xxxx-xxx-xxx-xxx', name=u'VPortMirror')
>>> vportmirror = NUVPortMirror(data=my_dict)
"""
super(NUVPortMirror, self).__init__()
# Read/Write Attributes
self._vport_name = None
self._last_updated_by = None
self._network_name = None
self._mirror_destination_id = None
self._mirror_destination_name = None
self._mirror_direction = None
self._enterpise_name = None
self._entity_scope = None
self._domain_name = None
self._vport_id = None
self._attached_network_type = None
self._external_id = None
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mirror_destination_id", remote_name="mirrorDestinationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mirror_destination_name", remote_name="mirrorDestinationName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mirror_direction", remote_name="mirrorDirection", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTH', u'EGRESS', u'INGRESS'])
self.expose_attribute(local_name="enterpise_name", remote_name="enterpiseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_id", remote_name="vportId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vport_name(self):
""" Get vport_name value.
Notes:
Name of the vport to which the mirror destination is associated with.
This attribute is named `VPortName` in VSD API.
"""
return self._vport_name
@vport_name.setter
def vport_name(self, value):
""" Set vport_name value.
Notes:
Name of the vport to which the mirror destination is associated with.
This attribute is named `VPortName` in VSD API.
"""
self._vport_name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def network_name(self):
""" Get network_name value.
Notes:
Name of the network to which the vport belongs to
This attribute is named `networkName` in VSD API.
"""
return self._network_name
@network_name.setter
def network_name(self, value):
""" Set network_name value.
Notes:
Name of the network to which the vport belongs to
This attribute is named `networkName` in VSD API.
"""
self._network_name = value
@property
def mirror_destination_id(self):
""" Get mirror_destination_id value.
Notes:
Destination ID of the mirror destination object.
This attribute is named `mirrorDestinationID` in VSD API.
"""
return self._mirror_destination_id
@mirror_destination_id.setter
def mirror_destination_id(self, value):
""" Set mirror_destination_id value.
Notes:
Destination ID of the mirror destination object.
This attribute is named `mirrorDestinationID` in VSD API.
"""
self._mirror_destination_id = value
@property
def mirror_destination_name(self):
""" Get mirror_destination_name value.
Notes:
Name of the mirror destination
This attribute is named `mirrorDestinationName` in VSD API.
"""
return self._mirror_destination_name
@mirror_destination_name.setter
def mirror_destination_name(self, value):
""" Set mirror_destination_name value.
Notes:
Name of the mirror destination
This attribute is named `mirrorDestinationName` in VSD API.
"""
self._mirror_destination_name = value
@property
def mirror_direction(self):
""" Get mirror_direction value.
Notes:
Describes what type of traffic needs to be mirrored.
This attribute is named `mirrorDirection` in VSD API.
"""
return self._mirror_direction
@mirror_direction.setter
def mirror_direction(self, value):
""" Set mirror_direction value.
Notes:
Describes what type of traffic needs to be mirrored.
This attribute is named `mirrorDirection` in VSD API.
"""
self._mirror_direction = value
@property
def enterpise_name(self):
""" Get enterpise_name value.
Notes:
Enterprise to which the vport associated with the mirror destination belongs to.
This attribute is named `enterpiseName` in VSD API.
"""
return self._enterpise_name
@enterpise_name.setter
def enterpise_name(self, value):
""" Set enterpise_name value.
Notes:
Enterprise to which the vport associated with the mirror destination belongs to.
This attribute is named `enterpiseName` in VSD API.
"""
self._enterpise_name = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def domain_name(self):
""" Get domain_name value.
Notes:
Domain name of the vport associated with the mirror destination
This attribute is named `domainName` in VSD API.
"""
return self._domain_name
@domain_name.setter
def domain_name(self, value):
""" Set domain_name value.
Notes:
Domain name of the vport associated with the mirror destination
This attribute is named `domainName` in VSD API.
"""
self._domain_name = value
@property
def vport_id(self):
""" Get vport_id value.
Notes:
Id of the vport to which the mirror destination is associated with.
This attribute is named `vportId` in VSD API.
"""
return self._vport_id
@vport_id.setter
def vport_id(self, value):
""" Set vport_id value.
Notes:
Id of the vport to which the mirror destination is associated with.
This attribute is named `vportId` in VSD API.
"""
self._vport_id = value
@property
def attached_network_type(self):
""" Get attached_network_type value.
Notes:
Type of the network attached - L2/L3
This attribute is named `attachedNetworkType` in VSD API.
"""
return self._attached_network_type
@attached_network_type.setter
def attached_network_type(self, value):
""" Set attached_network_type value.
Notes:
Type of the network attached - L2/L3
This attribute is named `attachedNetworkType` in VSD API.
"""
self._attached_network_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVPortMirror
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MIRROR_DIRECTION_BOTH
var CONST_MIRROR_DIRECTION_EGRESS
var CONST_MIRROR_DIRECTION_INGRESS
var resource_name
var rest_name
Instance variables
var attached_network_type
Get attached_network_type value.
Notes: Type of the network attached - L2/L3
This attribute is named `attachedNetworkType` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var domain_name
Get domain_name value.
Notes: Domain name of the vport associated with the mirror destination
This attribute is named `domainName` in VSD API.
var enterpise_name
Get enterpise_name value.
Notes: Enterprise to which the vport associated with the mirror destination belongs to.
This attribute is named `enterpiseName` in VSD API.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var mirror_destination_id
Get mirror_destination_id value.
Notes: Destination ID of the mirror destination object.
This attribute is named `mirrorDestinationID` in VSD API.
var mirror_destination_name
Get mirror_destination_name value.
Notes: Name of the mirror destination
This attribute is named `mirrorDestinationName` in VSD API.
var mirror_direction
Get mirror_direction value.
Notes: Describes what type of traffic needs to be mirrored.
This attribute is named `mirrorDirection` in VSD API.
var network_name
Get network_name value.
Notes: Name of the network to which the vport belongs to
This attribute is named `networkName` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var vport_id
Get vport_id value.
Notes: Id of the vport to which the mirror destination is associated with.
This attribute is named `vportId` in VSD API.
var vport_name
Get vport_name value.
Notes: Name of the vport to which the mirror destination is associated with.
This attribute is named `VPortName` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VPortMirror instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vportmirror = NUVPortMirror(id=u'xxxx-xxx-xxx-xxx', name=u'VPortMirror') >>> vportmirror = NUVPortMirror(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VPortMirror instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vportmirror = NUVPortMirror(id=u'xxxx-xxx-xxx-xxx', name=u'VPortMirror')
>>> vportmirror = NUVPortMirror(data=my_dict)
"""
super(NUVPortMirror, self).__init__()
# Read/Write Attributes
self._vport_name = None
self._last_updated_by = None
self._network_name = None
self._mirror_destination_id = None
self._mirror_destination_name = None
self._mirror_direction = None
self._enterpise_name = None
self._entity_scope = None
self._domain_name = None
self._vport_id = None
self._attached_network_type = None
self._external_id = None
self.expose_attribute(local_name="vport_name", remote_name="VPortName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="network_name", remote_name="networkName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mirror_destination_id", remote_name="mirrorDestinationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mirror_destination_name", remote_name="mirrorDestinationName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mirror_direction", remote_name="mirrorDirection", attribute_type=str, is_required=False, is_unique=False, choices=[u'BOTH', u'EGRESS', u'INGRESS'])
self.expose_attribute(local_name="enterpise_name", remote_name="enterpiseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vport_id", remote_name="vportId", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="attached_network_type", remote_name="attachedNetworkType", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVRS
Represents a VRS in the VSD
Notes: System Monitoring details for VRS connected to VSC or HSC
class NUVRS(NURESTObject):
""" Represents a VRS in the VSD
Notes:
System Monitoring details for VRS connected to VSC or HSC
"""
__rest_name__ = "vrs"
__resource_name__ = "vrss"
## Constants
CONST_STATUS_DOWN = "DOWN"
CONST_CLUSTER_NODE_ROLE_NONE = "NONE"
CONST_HYPERVISOR_CONNECTION_STATE_UP = "UP"
CONST_HYPERVISOR_CONNECTION_STATE_ADMIN_DOWN = "ADMIN_DOWN"
CONST_PERSONALITY_NONE = "NONE"
CONST_HYPERVISOR_CONNECTION_STATE_DOWN = "DOWN"
CONST_CLUSTER_NODE_ROLE_SECONDARY = "SECONDARY"
CONST_PERSONALITY_VRS = "VRS"
CONST_PERSONALITY_NSG = "NSG"
CONST_ROLE_MASTER = "MASTER"
CONST_STATUS_ADMIN_DOWN = "ADMIN_DOWN"
CONST_ROLE_SLAVE = "SLAVE"
CONST_PERSONALITY_HARDWARE_VTEP = "HARDWARE_VTEP"
CONST_JSONRPC_CONNECTION_STATE_UP = "UP"
CONST_JSONRPC_CONNECTION_STATE_ADMIN_DOWN = "ADMIN_DOWN"
CONST_STATUS_UP = "UP"
CONST_PERSONALITY_VRSG = "VRSG"
CONST_CLUSTER_NODE_ROLE_PRIMARY = "PRIMARY"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_JSONRPC_CONNECTION_STATE_DOWN = "DOWN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ROLE_NONE = "NONE"
def __init__(self, **kwargs):
""" Initializes a VRS instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vrs = NUVRS(id=u'xxxx-xxx-xxx-xxx', name=u'VRS')
>>> vrs = NUVRS(data=my_dict)
"""
super(NUVRS, self).__init__()
# Read/Write Attributes
self._jsonrpc_connection_state = None
self._name = None
self._management_ip = None
self._parent_ids = None
self._last_event_name = None
self._last_event_object = None
self._last_event_timestamp = None
self._last_state_change = None
self._last_updated_by = None
self._db_synced = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._peer = None
self._personality = None
self._description = None
self._messages = None
self._disks = None
self._cluster_node_role = None
self._entity_scope = None
self._location = None
self._role = None
self._uptime = None
self._product_version = None
self._is_resilient = None
self._status = None
self._multi_nic_vport_enabled = None
self._number_of_bridge_interfaces = None
self._number_of_host_interfaces = None
self._number_of_virtual_machines = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self._dynamic = None
self._hypervisor_connection_state = None
self._hypervisor_identifier = None
self._hypervisor_name = None
self._hypervisor_type = None
self.expose_attribute(local_name="jsonrpc_connection_state", remote_name="JSONRPCConnectionState", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="parent_ids", remote_name="parentIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_event_name", remote_name="lastEventName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_event_object", remote_name="lastEventObject", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_event_timestamp", remote_name="lastEventTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="db_synced", remote_name="dbSynced", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer", remote_name="peer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'HARDWARE_VTEP', u'NONE', u'NSG', u'VRS', u'VRSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="cluster_node_role", remote_name="clusterNodeRole", attribute_type=str, is_required=False, is_unique=False, choices=[u'NONE', u'PRIMARY', u'SECONDARY'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="role", remote_name="role", attribute_type=str, is_required=False, is_unique=False, choices=[u'MASTER', u'NONE', u'SLAVE'])
self.expose_attribute(local_name="uptime", remote_name="uptime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="is_resilient", remote_name="isResilient", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="multi_nic_vport_enabled", remote_name="multiNICVPortEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_bridge_interfaces", remote_name="numberOfBridgeInterfaces", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_host_interfaces", remote_name="numberOfHostInterfaces", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_virtual_machines", remote_name="numberOfVirtualMachines", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="dynamic", remote_name="dynamic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="hypervisor_connection_state", remote_name="hypervisorConnectionState", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="hypervisor_identifier", remote_name="hypervisorIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="hypervisor_name", remote_name="hypervisorName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="hypervisor_type", remote_name="hypervisorType", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.monitoring_ports = NUMonitoringPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.hscs = NUHSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vscs = NUVSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_nic_vports = NUMultiNICVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def jsonrpc_connection_state(self):
""" Get jsonrpc_connection_state value.
Notes:
The current JSON RPC connection status.
This attribute is named `JSONRPCConnectionState` in VSD API.
"""
return self._jsonrpc_connection_state
@jsonrpc_connection_state.setter
def jsonrpc_connection_state(self, value):
""" Set jsonrpc_connection_state value.
Notes:
The current JSON RPC connection status.
This attribute is named `JSONRPCConnectionState` in VSD API.
"""
self._jsonrpc_connection_state = value
@property
def name(self):
""" Get name value.
Notes:
Identifies the entity with a name.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Identifies the entity with a name.
"""
self._name = value
@property
def management_ip(self):
""" Get management_ip value.
Notes:
The management IP of the VRS entity
This attribute is named `managementIP` in VSD API.
"""
return self._management_ip
@management_ip.setter
def management_ip(self, value):
""" Set management_ip value.
Notes:
The management IP of the VRS entity
This attribute is named `managementIP` in VSD API.
"""
self._management_ip = value
@property
def parent_ids(self):
""" Get parent_ids value.
Notes:
Holds VRS controllers ids
This attribute is named `parentIDs` in VSD API.
"""
return self._parent_ids
@parent_ids.setter
def parent_ids(self, value):
""" Set parent_ids value.
Notes:
Holds VRS controllers ids
This attribute is named `parentIDs` in VSD API.
"""
self._parent_ids = value
@property
def last_event_name(self):
""" Get last_event_name value.
Notes:
The last event name from the hypervisor.
This attribute is named `lastEventName` in VSD API.
"""
return self._last_event_name
@last_event_name.setter
def last_event_name(self, value):
""" Set last_event_name value.
Notes:
The last event name from the hypervisor.
This attribute is named `lastEventName` in VSD API.
"""
self._last_event_name = value
@property
def last_event_object(self):
""" Get last_event_object value.
Notes:
The last event object (including metadata) from the hypervisor.
This attribute is named `lastEventObject` in VSD API.
"""
return self._last_event_object
@last_event_object.setter
def last_event_object(self, value):
""" Set last_event_object value.
Notes:
The last event object (including metadata) from the hypervisor.
This attribute is named `lastEventObject` in VSD API.
"""
self._last_event_object = value
@property
def last_event_timestamp(self):
""" Get last_event_timestamp value.
Notes:
The last event timestamp from the hypervisor.
This attribute is named `lastEventTimestamp` in VSD API.
"""
return self._last_event_timestamp
@last_event_timestamp.setter
def last_event_timestamp(self, value):
""" Set last_event_timestamp value.
Notes:
The last event timestamp from the hypervisor.
This attribute is named `lastEventTimestamp` in VSD API.
"""
self._last_event_timestamp = value
@property
def last_state_change(self):
""" Get last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
return self._last_state_change
@last_state_change.setter
def last_state_change(self, value):
""" Set last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
self._last_state_change = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def db_synced(self):
""" Get db_synced value.
Notes:
Flag to indicate if the ovs database is synced between the NSG pair part of a redundant group
This attribute is named `dbSynced` in VSD API.
"""
return self._db_synced
@db_synced.setter
def db_synced(self, value):
""" Set db_synced value.
Notes:
Flag to indicate if the ovs database is synced between the NSG pair part of a redundant group
This attribute is named `dbSynced` in VSD API.
"""
self._db_synced = value
@property
def address(self):
""" Get address value.
Notes:
The IP of the VRS entity
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
The IP of the VRS entity
"""
self._address = value
@property
def peak_cpuusage(self):
""" Get peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
return self._peak_cpuusage
@peak_cpuusage.setter
def peak_cpuusage(self, value):
""" Set peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
self._peak_cpuusage = value
@property
def peak_memory_usage(self):
""" Get peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
return self._peak_memory_usage
@peak_memory_usage.setter
def peak_memory_usage(self, value):
""" Set peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
self._peak_memory_usage = value
@property
def peer(self):
""" Get peer value.
Notes:
The redundant peer id for the current VRS.
"""
return self._peer
@peer.setter
def peer(self, value):
""" Set peer value.
Notes:
The redundant peer id for the current VRS.
"""
self._peer = value
@property
def personality(self):
""" Get personality value.
Notes:
VRS personality.
"""
return self._personality
@personality.setter
def personality(self, value):
""" Set personality value.
Notes:
VRS personality.
"""
self._personality = value
@property
def description(self):
""" Get description value.
Notes:
Description of the entity.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the entity.
"""
self._description = value
@property
def messages(self):
""" Get messages value.
Notes:
An array of degraded messages.
"""
return self._messages
@messages.setter
def messages(self, value):
""" Set messages value.
Notes:
An array of degraded messages.
"""
self._messages = value
@property
def disks(self):
""" Get disks value.
Notes:
Set of disk usage details.
"""
return self._disks
@disks.setter
def disks(self, value):
""" Set disks value.
Notes:
Set of disk usage details.
"""
self._disks = value
@property
def cluster_node_role(self):
""" Get cluster_node_role value.
Notes:
Indicate that the controller associated is primary, secondary or unknown.
This attribute is named `clusterNodeRole` in VSD API.
"""
return self._cluster_node_role
@cluster_node_role.setter
def cluster_node_role(self, value):
""" Set cluster_node_role value.
Notes:
Indicate that the controller associated is primary, secondary or unknown.
This attribute is named `clusterNodeRole` in VSD API.
"""
self._cluster_node_role = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location(self):
""" Get location value.
Notes:
Identifies the entity to be associated with a location.
"""
return self._location
@location.setter
def location(self, value):
""" Set location value.
Notes:
Identifies the entity to be associated with a location.
"""
self._location = value
@property
def role(self):
""" Get role value.
Notes:
Flag to indicate that VRS-G redundancy state (active/standby/standalone). Only applicable for gateways.
"""
return self._role
@role.setter
def role(self, value):
""" Set role value.
Notes:
Flag to indicate that VRS-G redundancy state (active/standby/standalone). Only applicable for gateways.
"""
self._role = value
@property
def uptime(self):
""" Get uptime value.
Notes:
How long the VRS was up.
"""
return self._uptime
@uptime.setter
def uptime(self, value):
""" Set uptime value.
Notes:
How long the VRS was up.
"""
self._uptime = value
@property
def product_version(self):
""" Get product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
return self._product_version
@product_version.setter
def product_version(self, value):
""" Set product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
self._product_version = value
@property
def is_resilient(self):
""" Get is_resilient value.
Notes:
Flag to indicate that the VRS is part of a redundant group.
This attribute is named `isResilient` in VSD API.
"""
return self._is_resilient
@is_resilient.setter
def is_resilient(self, value):
""" Set is_resilient value.
Notes:
Flag to indicate that the VRS is part of a redundant group.
This attribute is named `isResilient` in VSD API.
"""
self._is_resilient = value
@property
def status(self):
""" Get status value.
Notes:
Computed status of the entity.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Computed status of the entity.
"""
self._status = value
@property
def multi_nic_vport_enabled(self):
""" Get multi_nic_vport_enabled value.
Notes:
VRS is in Multi-NIC VPORT Mode
This attribute is named `multiNICVPortEnabled` in VSD API.
"""
return self._multi_nic_vport_enabled
@multi_nic_vport_enabled.setter
def multi_nic_vport_enabled(self, value):
""" Set multi_nic_vport_enabled value.
Notes:
VRS is in Multi-NIC VPORT Mode
This attribute is named `multiNICVPortEnabled` in VSD API.
"""
self._multi_nic_vport_enabled = value
@property
def number_of_bridge_interfaces(self):
""" Get number_of_bridge_interfaces value.
Notes:
Number of bridge interfaces defined in this VRS.
This attribute is named `numberOfBridgeInterfaces` in VSD API.
"""
return self._number_of_bridge_interfaces
@number_of_bridge_interfaces.setter
def number_of_bridge_interfaces(self, value):
""" Set number_of_bridge_interfaces value.
Notes:
Number of bridge interfaces defined in this VRS.
This attribute is named `numberOfBridgeInterfaces` in VSD API.
"""
self._number_of_bridge_interfaces = value
@property
def number_of_host_interfaces(self):
""" Get number_of_host_interfaces value.
Notes:
Number of host interfaces defined in this VRS.
This attribute is named `numberOfHostInterfaces` in VSD API.
"""
return self._number_of_host_interfaces
@number_of_host_interfaces.setter
def number_of_host_interfaces(self, value):
""" Set number_of_host_interfaces value.
Notes:
Number of host interfaces defined in this VRS.
This attribute is named `numberOfHostInterfaces` in VSD API.
"""
self._number_of_host_interfaces = value
@property
def number_of_virtual_machines(self):
""" Get number_of_virtual_machines value.
Notes:
Number of VMs defined in this VRS.
This attribute is named `numberOfVirtualMachines` in VSD API.
"""
return self._number_of_virtual_machines
@number_of_virtual_machines.setter
def number_of_virtual_machines(self, value):
""" Set number_of_virtual_machines value.
Notes:
Number of VMs defined in this VRS.
This attribute is named `numberOfVirtualMachines` in VSD API.
"""
self._number_of_virtual_machines = value
@property
def current_cpuusage(self):
""" Get current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
return self._current_cpuusage
@current_cpuusage.setter
def current_cpuusage(self, value):
""" Set current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
self._current_cpuusage = value
@property
def current_memory_usage(self):
""" Get current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
return self._current_memory_usage
@current_memory_usage.setter
def current_memory_usage(self, value):
""" Set current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
self._current_memory_usage = value
@property
def average_cpuusage(self):
""" Get average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
return self._average_cpuusage
@average_cpuusage.setter
def average_cpuusage(self, value):
""" Set average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
self._average_cpuusage = value
@property
def average_memory_usage(self):
""" Get average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
return self._average_memory_usage
@average_memory_usage.setter
def average_memory_usage(self, value):
""" Set average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
self._average_memory_usage = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def dynamic(self):
""" Get dynamic value.
Notes:
Flag to indicate it is dynamically configured or not.
"""
return self._dynamic
@dynamic.setter
def dynamic(self, value):
""" Set dynamic value.
Notes:
Flag to indicate it is dynamically configured or not.
"""
self._dynamic = value
@property
def hypervisor_connection_state(self):
""" Get hypervisor_connection_state value.
Notes:
The VRS connection state with the hypervisor.
This attribute is named `hypervisorConnectionState` in VSD API.
"""
return self._hypervisor_connection_state
@hypervisor_connection_state.setter
def hypervisor_connection_state(self, value):
""" Set hypervisor_connection_state value.
Notes:
The VRS connection state with the hypervisor.
This attribute is named `hypervisorConnectionState` in VSD API.
"""
self._hypervisor_connection_state = value
@property
def hypervisor_identifier(self):
""" Get hypervisor_identifier value.
Notes:
The hypervisor IP (or name) associated with the VRS.
This attribute is named `hypervisorIdentifier` in VSD API.
"""
return self._hypervisor_identifier
@hypervisor_identifier.setter
def hypervisor_identifier(self, value):
""" Set hypervisor_identifier value.
Notes:
The hypervisor IP (or name) associated with the VRS.
This attribute is named `hypervisorIdentifier` in VSD API.
"""
self._hypervisor_identifier = value
@property
def hypervisor_name(self):
""" Get hypervisor_name value.
Notes:
The hypervisor name associated with the VRS.
This attribute is named `hypervisorName` in VSD API.
"""
return self._hypervisor_name
@hypervisor_name.setter
def hypervisor_name(self, value):
""" Set hypervisor_name value.
Notes:
The hypervisor name associated with the VRS.
This attribute is named `hypervisorName` in VSD API.
"""
self._hypervisor_name = value
@property
def hypervisor_type(self):
""" Get hypervisor_type value.
Notes:
The hypervisor type associated with the VRS.
This attribute is named `hypervisorType` in VSD API.
"""
return self._hypervisor_type
@hypervisor_type.setter
def hypervisor_type(self, value):
""" Set hypervisor_type value.
Notes:
The hypervisor type associated with the VRS.
This attribute is named `hypervisorType` in VSD API.
"""
self._hypervisor_type = value
Ancestors (in MRO)
- NUVRS
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_CLUSTER_NODE_ROLE_NONE
var CONST_CLUSTER_NODE_ROLE_PRIMARY
var CONST_CLUSTER_NODE_ROLE_SECONDARY
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_HYPERVISOR_CONNECTION_STATE_ADMIN_DOWN
var CONST_HYPERVISOR_CONNECTION_STATE_DOWN
var CONST_HYPERVISOR_CONNECTION_STATE_UP
var CONST_JSONRPC_CONNECTION_STATE_ADMIN_DOWN
var CONST_JSONRPC_CONNECTION_STATE_DOWN
var CONST_JSONRPC_CONNECTION_STATE_UP
var CONST_PERSONALITY_HARDWARE_VTEP
var CONST_PERSONALITY_NONE
var CONST_PERSONALITY_NSG
var CONST_PERSONALITY_VRS
var CONST_PERSONALITY_VRSG
var CONST_ROLE_MASTER
var CONST_ROLE_NONE
var CONST_ROLE_SLAVE
var CONST_STATUS_ADMIN_DOWN
var CONST_STATUS_DOWN
var CONST_STATUS_UP
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: The IP of the VRS entity
var alarms
var average_cpuusage
Get average_cpuusage value.
Notes: Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
var average_memory_usage
Get average_memory_usage value.
Notes: Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var cluster_node_role
Get cluster_node_role value.
Notes: Indicate that the controller associated is primary, secondary or unknown.
This attribute is named `clusterNodeRole` in VSD API.
var creation_date
Get creation date
var current_cpuusage
Get current_cpuusage value.
Notes: Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
var current_memory_usage
Get current_memory_usage value.
Notes: Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
var db_synced
Get db_synced value.
Notes: Flag to indicate if the ovs database is synced between the NSG pair part of a redundant group
This attribute is named `dbSynced` in VSD API.
var description
Get description value.
Notes: Description of the entity.
var disks
Get disks value.
Notes: Set of disk usage details.
var dynamic
Get dynamic value.
Notes: Flag to indicate it is dynamically configured or not.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var hscs
var hypervisor_connection_state
Get hypervisor_connection_state value.
Notes: The VRS connection state with the hypervisor.
This attribute is named `hypervisorConnectionState` in VSD API.
var hypervisor_identifier
Get hypervisor_identifier value.
Notes: The hypervisor IP (or name) associated with the VRS.
This attribute is named `hypervisorIdentifier` in VSD API.
var hypervisor_name
Get hypervisor_name value.
Notes: The hypervisor name associated with the VRS.
This attribute is named `hypervisorName` in VSD API.
var hypervisor_type
Get hypervisor_type value.
Notes: The hypervisor type associated with the VRS.
This attribute is named `hypervisorType` in VSD API.
var id
Get object id
var is_resilient
Get is_resilient value.
Notes: Flag to indicate that the VRS is part of a redundant group.
This attribute is named `isResilient` in VSD API.
var jobs
var jsonrpc_connection_state
Get jsonrpc_connection_state value.
Notes: The current JSON RPC connection status.
This attribute is named `JSONRPCConnectionState` in VSD API.
var last_event_name
Get last_event_name value.
Notes: The last event name from the hypervisor.
This attribute is named `lastEventName` in VSD API.
var last_event_object
Get last_event_object value.
Notes: The last event object (including metadata) from the hypervisor.
This attribute is named `lastEventObject` in VSD API.
var last_event_timestamp
Get last_event_timestamp value.
Notes: The last event timestamp from the hypervisor.
This attribute is named `lastEventTimestamp` in VSD API.
var last_state_change
Get last_state_change value.
Notes: Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location
Get location value.
Notes: Identifies the entity to be associated with a location.
var management_ip
Get management_ip value.
Notes: The management IP of the VRS entity
This attribute is named `managementIP` in VSD API.
var messages
Get messages value.
Notes: An array of degraded messages.
var metadatas
var monitoring_ports
var multi_nic_vport_enabled
Get multi_nic_vport_enabled value.
Notes: VRS is in Multi-NIC VPORT Mode
This attribute is named `multiNICVPortEnabled` in VSD API.
var multi_nic_vports
var name
Get name value.
Notes: Identifies the entity with a name.
var number_of_bridge_interfaces
Get number_of_bridge_interfaces value.
Notes: Number of bridge interfaces defined in this VRS.
This attribute is named `numberOfBridgeInterfaces` in VSD API.
var number_of_host_interfaces
Get number_of_host_interfaces value.
Notes: Number of host interfaces defined in this VRS.
This attribute is named `numberOfHostInterfaces` in VSD API.
var number_of_virtual_machines
Get number_of_virtual_machines value.
Notes: Number of VMs defined in this VRS.
This attribute is named `numberOfVirtualMachines` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_ids
Get parent_ids value.
Notes: Holds VRS controllers ids
This attribute is named `parentIDs` in VSD API.
var parent_object
Get parent
var parent_type
Get parent type
var peak_cpuusage
Get peak_cpuusage value.
Notes: Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
var peak_memory_usage
Get peak_memory_usage value.
Notes: Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
var peer
Get peer value.
Notes: The redundant peer id for the current VRS.
var personality
Get personality value.
Notes: VRS personality.
var product_version
Get product_version value.
Notes: Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
var role
Get role value.
Notes: Flag to indicate that VRS-G redundancy state (active/standby/standalone). Only applicable for gateways.
var status
Get status value.
Notes: Computed status of the entity.
var uptime
Get uptime value.
Notes: How long the VRS was up.
var vms
var vports
var vscs
Methods
def __init__(
self, **kwargs)
Initializes a VRS instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vrs = NUVRS(id=u'xxxx-xxx-xxx-xxx', name=u'VRS') >>> vrs = NUVRS(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VRS instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vrs = NUVRS(id=u'xxxx-xxx-xxx-xxx', name=u'VRS')
>>> vrs = NUVRS(data=my_dict)
"""
super(NUVRS, self).__init__()
# Read/Write Attributes
self._jsonrpc_connection_state = None
self._name = None
self._management_ip = None
self._parent_ids = None
self._last_event_name = None
self._last_event_object = None
self._last_event_timestamp = None
self._last_state_change = None
self._last_updated_by = None
self._db_synced = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._peer = None
self._personality = None
self._description = None
self._messages = None
self._disks = None
self._cluster_node_role = None
self._entity_scope = None
self._location = None
self._role = None
self._uptime = None
self._product_version = None
self._is_resilient = None
self._status = None
self._multi_nic_vport_enabled = None
self._number_of_bridge_interfaces = None
self._number_of_host_interfaces = None
self._number_of_virtual_machines = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self._dynamic = None
self._hypervisor_connection_state = None
self._hypervisor_identifier = None
self._hypervisor_name = None
self._hypervisor_type = None
self.expose_attribute(local_name="jsonrpc_connection_state", remote_name="JSONRPCConnectionState", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="parent_ids", remote_name="parentIDs", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_event_name", remote_name="lastEventName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_event_object", remote_name="lastEventObject", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_event_timestamp", remote_name="lastEventTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="db_synced", remote_name="dbSynced", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer", remote_name="peer", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="personality", remote_name="personality", attribute_type=str, is_required=False, is_unique=False, choices=[u'HARDWARE_VTEP', u'NONE', u'NSG', u'VRS', u'VRSG'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="cluster_node_role", remote_name="clusterNodeRole", attribute_type=str, is_required=False, is_unique=False, choices=[u'NONE', u'PRIMARY', u'SECONDARY'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="role", remote_name="role", attribute_type=str, is_required=False, is_unique=False, choices=[u'MASTER', u'NONE', u'SLAVE'])
self.expose_attribute(local_name="uptime", remote_name="uptime", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="is_resilient", remote_name="isResilient", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="multi_nic_vport_enabled", remote_name="multiNICVPortEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_bridge_interfaces", remote_name="numberOfBridgeInterfaces", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_host_interfaces", remote_name="numberOfHostInterfaces", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="number_of_virtual_machines", remote_name="numberOfVirtualMachines", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="dynamic", remote_name="dynamic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="hypervisor_connection_state", remote_name="hypervisorConnectionState", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="hypervisor_identifier", remote_name="hypervisorIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="hypervisor_name", remote_name="hypervisorName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="hypervisor_type", remote_name="hypervisorType", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.monitoring_ports = NUMonitoringPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.hscs = NUHSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vscs = NUVSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.multi_nic_vports = NUMultiNICVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVRSAddressRange
Represents a VRSAddressRange in the VSD
Notes: This is the definition of a Address Range associated with a VRS.
class NUVRSAddressRange(NURESTObject):
""" Represents a VRSAddressRange in the VSD
Notes:
This is the definition of a Address Range associated with a VRS.
"""
__rest_name__ = "vrsaddressrange"
__resource_name__ = "vrsaddressranges"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VRSAddressRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vrsaddressrange = NUVRSAddressRange(id=u'xxxx-xxx-xxx-xxx', name=u'VRSAddressRange')
>>> vrsaddressrange = NUVRSAddressRange(data=my_dict)
"""
super(NUVRSAddressRange, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._max_address = None
self._min_address = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_address", remote_name="maxAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="min_address", remote_name="minAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def max_address(self):
""" Get max_address value.
Notes:
Higest address in the address range
This attribute is named `maxAddress` in VSD API.
"""
return self._max_address
@max_address.setter
def max_address(self, value):
""" Set max_address value.
Notes:
Higest address in the address range
This attribute is named `maxAddress` in VSD API.
"""
self._max_address = value
@property
def min_address(self):
""" Get min_address value.
Notes:
Lowest address in the address range
This attribute is named `minAddress` in VSD API.
"""
return self._min_address
@min_address.setter
def min_address(self, value):
""" Set min_address value.
Notes:
Lowest address in the address range
This attribute is named `minAddress` in VSD API.
"""
self._min_address = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVRSAddressRange
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var max_address
Get max_address value.
Notes: Higest address in the address range
This attribute is named `maxAddress` in VSD API.
var metadatas
var min_address
Get min_address value.
Notes: Lowest address in the address range
This attribute is named `minAddress` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
Methods
def __init__(
self, **kwargs)
Initializes a VRSAddressRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vrsaddressrange = NUVRSAddressRange(id=u'xxxx-xxx-xxx-xxx', name=u'VRSAddressRange') >>> vrsaddressrange = NUVRSAddressRange(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VRSAddressRange instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vrsaddressrange = NUVRSAddressRange(id=u'xxxx-xxx-xxx-xxx', name=u'VRSAddressRange')
>>> vrsaddressrange = NUVRSAddressRange(data=my_dict)
"""
super(NUVRSAddressRange, self).__init__()
# Read/Write Attributes
self._last_updated_by = None
self._max_address = None
self._min_address = None
self._entity_scope = None
self._external_id = None
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="max_address", remote_name="maxAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="min_address", remote_name="minAddress", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVSC
Represents a VSC in the VSD
Notes: System Monitoring details for VSC.
class NUVSC(NURESTObject):
""" Represents a VSC in the VSD
Notes:
System Monitoring details for VSC.
"""
__rest_name__ = "vsc"
__resource_name__ = "vscs"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_STATUS_DOWN = "DOWN"
CONST_STATUS_UP = "UP"
CONST_STATUS_ADMIN_DOWN = "ADMIN_DOWN"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VSC instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsc = NUVSC(id=u'xxxx-xxx-xxx-xxx', name=u'VSC')
>>> vsc = NUVSC(data=my_dict)
"""
super(NUVSC, self).__init__()
# Read/Write Attributes
self._name = None
self._management_ip = None
self._last_state_change = None
self._last_updated_by = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._description = None
self._messages = None
self._disks = None
self._already_marked_for_unavailable = None
self._unavailable_timestamp = None
self._entity_scope = None
self._location = None
self._product_version = None
self._vsds = None
self._status = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="already_marked_for_unavailable", remote_name="alreadyMarkedForUnavailable", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="unavailable_timestamp", remote_name="unavailableTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsds", remote_name="vsds", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bgp_peers = NUBGPPeersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.monitoring_ports = NUMonitoringPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Identifies the entity with a name.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Identifies the entity with a name.
"""
self._name = value
@property
def management_ip(self):
""" Get management_ip value.
Notes:
The management IP of the VSC/HSC entity
This attribute is named `managementIP` in VSD API.
"""
return self._management_ip
@management_ip.setter
def management_ip(self, value):
""" Set management_ip value.
Notes:
The management IP of the VSC/HSC entity
This attribute is named `managementIP` in VSD API.
"""
self._management_ip = value
@property
def last_state_change(self):
""" Get last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
return self._last_state_change
@last_state_change.setter
def last_state_change(self, value):
""" Set last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
self._last_state_change = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
The IP of the VRS entity
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
The IP of the VRS entity
"""
self._address = value
@property
def peak_cpuusage(self):
""" Get peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
return self._peak_cpuusage
@peak_cpuusage.setter
def peak_cpuusage(self, value):
""" Set peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
self._peak_cpuusage = value
@property
def peak_memory_usage(self):
""" Get peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
return self._peak_memory_usage
@peak_memory_usage.setter
def peak_memory_usage(self, value):
""" Set peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
self._peak_memory_usage = value
@property
def description(self):
""" Get description value.
Notes:
Description of the entity.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the entity.
"""
self._description = value
@property
def messages(self):
""" Get messages value.
Notes:
An array of degraded messages.
"""
return self._messages
@messages.setter
def messages(self, value):
""" Set messages value.
Notes:
An array of degraded messages.
"""
self._messages = value
@property
def disks(self):
""" Get disks value.
Notes:
Set of disk usage details.
"""
return self._disks
@disks.setter
def disks(self, value):
""" Set disks value.
Notes:
Set of disk usage details.
"""
self._disks = value
@property
def already_marked_for_unavailable(self):
""" Get already_marked_for_unavailable value.
Notes:
Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
"""
return self._already_marked_for_unavailable
@already_marked_for_unavailable.setter
def already_marked_for_unavailable(self, value):
""" Set already_marked_for_unavailable value.
Notes:
Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
"""
self._already_marked_for_unavailable = value
@property
def unavailable_timestamp(self):
""" Get unavailable_timestamp value.
Notes:
The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
"""
return self._unavailable_timestamp
@unavailable_timestamp.setter
def unavailable_timestamp(self, value):
""" Set unavailable_timestamp value.
Notes:
The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
"""
self._unavailable_timestamp = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location(self):
""" Get location value.
Notes:
Identifies the entity to be associated with a location.
"""
return self._location
@location.setter
def location(self, value):
""" Set location value.
Notes:
Identifies the entity to be associated with a location.
"""
self._location = value
@property
def product_version(self):
""" Get product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
return self._product_version
@product_version.setter
def product_version(self, value):
""" Set product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
self._product_version = value
@property
def vsds(self):
""" Get vsds value.
Notes:
A collection of VSD id(s) which are identified by this controller.
"""
return self._vsds
@vsds.setter
def vsds(self, value):
""" Set vsds value.
Notes:
A collection of VSD id(s) which are identified by this controller.
"""
self._vsds = value
@property
def status(self):
""" Get status value.
Notes:
Computed status of the entity.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Computed status of the entity.
"""
self._status = value
@property
def current_cpuusage(self):
""" Get current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
return self._current_cpuusage
@current_cpuusage.setter
def current_cpuusage(self, value):
""" Set current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
self._current_cpuusage = value
@property
def current_memory_usage(self):
""" Get current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
return self._current_memory_usage
@current_memory_usage.setter
def current_memory_usage(self, value):
""" Set current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
self._current_memory_usage = value
@property
def average_cpuusage(self):
""" Get average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
return self._average_cpuusage
@average_cpuusage.setter
def average_cpuusage(self, value):
""" Set average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
self._average_cpuusage = value
@property
def average_memory_usage(self):
""" Get average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
return self._average_memory_usage
@average_memory_usage.setter
def average_memory_usage(self, value):
""" Set average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
self._average_memory_usage = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVSC
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_STATUS_ADMIN_DOWN
var CONST_STATUS_DOWN
var CONST_STATUS_UP
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: The IP of the VRS entity
var alarms
Get already_marked_for_unavailable value.
Notes: Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
var average_cpuusage
Get average_cpuusage value.
Notes: Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
var average_memory_usage
Get average_memory_usage value.
Notes: Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
var bgp_peers
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var current_cpuusage
Get current_cpuusage value.
Notes: Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
var current_memory_usage
Get current_memory_usage value.
Notes: Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
var description
Get description value.
Notes: Description of the entity.
var disks
Get disks value.
Notes: Set of disk usage details.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_state_change
Get last_state_change value.
Notes: Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location
Get location value.
Notes: Identifies the entity to be associated with a location.
var management_ip
Get management_ip value.
Notes: The management IP of the VSC/HSC entity
This attribute is named `managementIP` in VSD API.
var messages
Get messages value.
Notes: An array of degraded messages.
var metadatas
var monitoring_ports
var name
Get name value.
Notes: Identifies the entity with a name.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var peak_cpuusage
Get peak_cpuusage value.
Notes: Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
var peak_memory_usage
Get peak_memory_usage value.
Notes: Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
var product_version
Get product_version value.
Notes: Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
var status
Get status value.
Notes: Computed status of the entity.
Get unavailable_timestamp value.
Notes: The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
var vrss
var vsds
Get vsds value.
Notes: A collection of VSD id(s) which are identified by this controller.
Methods
def __init__(
self, **kwargs)
Initializes a VSC instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vsc = NUVSC(id=u'xxxx-xxx-xxx-xxx', name=u'VSC') >>> vsc = NUVSC(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VSC instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsc = NUVSC(id=u'xxxx-xxx-xxx-xxx', name=u'VSC')
>>> vsc = NUVSC(data=my_dict)
"""
super(NUVSC, self).__init__()
# Read/Write Attributes
self._name = None
self._management_ip = None
self._last_state_change = None
self._last_updated_by = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._description = None
self._messages = None
self._disks = None
self._already_marked_for_unavailable = None
self._unavailable_timestamp = None
self._entity_scope = None
self._location = None
self._product_version = None
self._vsds = None
self._status = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="already_marked_for_unavailable", remote_name="alreadyMarkedForUnavailable", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="unavailable_timestamp", remote_name="unavailableTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vsds", remote_name="vsds", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.bgp_peers = NUBGPPeersFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.monitoring_ports = NUMonitoringPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vrss = NUVRSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVSD
Represents a VSD in the VSD
Notes: System Monitoring details for VSD.
class NUVSD(NURESTObject):
""" Represents a VSD in the VSD
Notes:
System Monitoring details for VSD.
"""
__rest_name__ = "vsd"
__resource_name__ = "vsds"
## Constants
CONST_MODE_STANDALONE = "STANDALONE"
CONST_STATUS_DOWN = "DOWN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_MODE_CLUSTER = "CLUSTER"
CONST_STATUS_UP = "UP"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_STATUS_ADMIN_DOWN = "ADMIN_DOWN"
def __init__(self, **kwargs):
""" Initializes a VSD instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsd = NUVSD(id=u'xxxx-xxx-xxx-xxx', name=u'VSD')
>>> vsd = NUVSD(data=my_dict)
"""
super(NUVSD, self).__init__()
# Read/Write Attributes
self._url = None
self._name = None
self._management_ip = None
self._last_state_change = None
self._last_updated_by = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._peer_addresses = None
self._description = None
self._messages = None
self._disks = None
self._already_marked_for_unavailable = None
self._unavailable_timestamp = None
self._entity_scope = None
self._location = None
self._mode = None
self._product_version = None
self._status = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self.expose_attribute(local_name="url", remote_name="URL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer_addresses", remote_name="peerAddresses", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="already_marked_for_unavailable", remote_name="alreadyMarkedForUnavailable", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="unavailable_timestamp", remote_name="unavailableTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mode", remote_name="mode", attribute_type=str, is_required=False, is_unique=False, choices=[u'CLUSTER', u'STANDALONE'])
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsd_components = NUVSDComponentsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def url(self):
""" Get url value.
Notes:
An optional web url for management.
This attribute is named `URL` in VSD API.
"""
return self._url
@url.setter
def url(self, value):
""" Set url value.
Notes:
An optional web url for management.
This attribute is named `URL` in VSD API.
"""
self._url = value
@property
def name(self):
""" Get name value.
Notes:
Identifies the entity with a name.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Identifies the entity with a name.
"""
self._name = value
@property
def management_ip(self):
""" Get management_ip value.
Notes:
An optional management IP to log into this component.
This attribute is named `managementIP` in VSD API.
"""
return self._management_ip
@management_ip.setter
def management_ip(self, value):
""" Set management_ip value.
Notes:
An optional management IP to log into this component.
This attribute is named `managementIP` in VSD API.
"""
self._management_ip = value
@property
def last_state_change(self):
""" Get last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
return self._last_state_change
@last_state_change.setter
def last_state_change(self, value):
""" Set last_state_change value.
Notes:
Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
"""
self._last_state_change = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
An optional IP to access this component.
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
An optional IP to access this component.
"""
self._address = value
@property
def peak_cpuusage(self):
""" Get peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
return self._peak_cpuusage
@peak_cpuusage.setter
def peak_cpuusage(self, value):
""" Set peak_cpuusage value.
Notes:
Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
"""
self._peak_cpuusage = value
@property
def peak_memory_usage(self):
""" Get peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
return self._peak_memory_usage
@peak_memory_usage.setter
def peak_memory_usage(self, value):
""" Set peak_memory_usage value.
Notes:
Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
"""
self._peak_memory_usage = value
@property
def peer_addresses(self):
""" Get peer_addresses value.
Notes:
A comma separated list of peer addresses, if it is in cluster mode.
This attribute is named `peerAddresses` in VSD API.
"""
return self._peer_addresses
@peer_addresses.setter
def peer_addresses(self, value):
""" Set peer_addresses value.
Notes:
A comma separated list of peer addresses, if it is in cluster mode.
This attribute is named `peerAddresses` in VSD API.
"""
self._peer_addresses = value
@property
def description(self):
""" Get description value.
Notes:
Description of the entity.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the entity.
"""
self._description = value
@property
def messages(self):
""" Get messages value.
Notes:
An array of degraded messages.
"""
return self._messages
@messages.setter
def messages(self, value):
""" Set messages value.
Notes:
An array of degraded messages.
"""
self._messages = value
@property
def disks(self):
""" Get disks value.
Notes:
Set of disk usage details.
"""
return self._disks
@disks.setter
def disks(self, value):
""" Set disks value.
Notes:
Set of disk usage details.
"""
self._disks = value
@property
def already_marked_for_unavailable(self):
""" Get already_marked_for_unavailable value.
Notes:
Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
"""
return self._already_marked_for_unavailable
@already_marked_for_unavailable.setter
def already_marked_for_unavailable(self, value):
""" Set already_marked_for_unavailable value.
Notes:
Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
"""
self._already_marked_for_unavailable = value
@property
def unavailable_timestamp(self):
""" Get unavailable_timestamp value.
Notes:
The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
"""
return self._unavailable_timestamp
@unavailable_timestamp.setter
def unavailable_timestamp(self, value):
""" Set unavailable_timestamp value.
Notes:
The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
"""
self._unavailable_timestamp = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location(self):
""" Get location value.
Notes:
Identifies the entity to be associated with a location.
"""
return self._location
@location.setter
def location(self, value):
""" Set location value.
Notes:
Identifies the entity to be associated with a location.
"""
self._location = value
@property
def mode(self):
""" Get mode value.
Notes:
Standalone or cluster mode.
"""
return self._mode
@mode.setter
def mode(self, value):
""" Set mode value.
Notes:
Standalone or cluster mode.
"""
self._mode = value
@property
def product_version(self):
""" Get product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
return self._product_version
@product_version.setter
def product_version(self, value):
""" Set product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
self._product_version = value
@property
def status(self):
""" Get status value.
Notes:
Computed status of the entity.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Computed status of the entity.
"""
self._status = value
@property
def current_cpuusage(self):
""" Get current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
return self._current_cpuusage
@current_cpuusage.setter
def current_cpuusage(self, value):
""" Set current_cpuusage value.
Notes:
Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
"""
self._current_cpuusage = value
@property
def current_memory_usage(self):
""" Get current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
return self._current_memory_usage
@current_memory_usage.setter
def current_memory_usage(self, value):
""" Set current_memory_usage value.
Notes:
Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
"""
self._current_memory_usage = value
@property
def average_cpuusage(self):
""" Get average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
return self._average_cpuusage
@average_cpuusage.setter
def average_cpuusage(self, value):
""" Set average_cpuusage value.
Notes:
Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
"""
self._average_cpuusage = value
@property
def average_memory_usage(self):
""" Get average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
return self._average_memory_usage
@average_memory_usage.setter
def average_memory_usage(self, value):
""" Set average_memory_usage value.
Notes:
Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
"""
self._average_memory_usage = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVSD
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_MODE_CLUSTER
var CONST_MODE_STANDALONE
var CONST_STATUS_ADMIN_DOWN
var CONST_STATUS_DOWN
var CONST_STATUS_UP
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: An optional IP to access this component.
var alarms
Get already_marked_for_unavailable value.
Notes: Flag to indicate that it is already marked a unavailable.
This attribute is named `alreadyMarkedForUnavailable` in VSD API.
var average_cpuusage
Get average_cpuusage value.
Notes: Average CPU usage percentage.
This attribute is named `averageCPUUsage` in VSD API.
var average_memory_usage
Get average_memory_usage value.
Notes: Average memory usage percentage.
This attribute is named `averageMemoryUsage` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var current_cpuusage
Get current_cpuusage value.
Notes: Current CPU usage percentage.
This attribute is named `currentCPUUsage` in VSD API.
var current_memory_usage
Get current_memory_usage value.
Notes: Current memory usage percentage.
This attribute is named `currentMemoryUsage` in VSD API.
var description
Get description value.
Notes: Description of the entity.
var disks
Get disks value.
Notes: Set of disk usage details.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var jobs
var last_state_change
Get last_state_change value.
Notes: Last state change timestamp (in millis).
This attribute is named `lastStateChange` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location
Get location value.
Notes: Identifies the entity to be associated with a location.
var management_ip
Get management_ip value.
Notes: An optional management IP to log into this component.
This attribute is named `managementIP` in VSD API.
var messages
Get messages value.
Notes: An array of degraded messages.
var metadatas
var mode
Get mode value.
Notes: Standalone or cluster mode.
var name
Get name value.
Notes: Identifies the entity with a name.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var peak_cpuusage
Get peak_cpuusage value.
Notes: Peek CPU usage percentage.
This attribute is named `peakCPUUsage` in VSD API.
var peak_memory_usage
Get peak_memory_usage value.
Notes: Peek memory usage percentage.
This attribute is named `peakMemoryUsage` in VSD API.
var peer_addresses
Get peer_addresses value.
Notes: A comma separated list of peer addresses, if it is in cluster mode.
This attribute is named `peerAddresses` in VSD API.
var product_version
Get product_version value.
Notes: Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
var status
Get status value.
Notes: Computed status of the entity.
Get unavailable_timestamp value.
Notes: The duration the controller is unavailable (in millis).
This attribute is named `unavailableTimestamp` in VSD API.
var url
Get url value.
Notes: An optional web url for management.
This attribute is named `URL` in VSD API.
var vsd_components
Methods
def __init__(
self, **kwargs)
Initializes a VSD instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vsd = NUVSD(id=u'xxxx-xxx-xxx-xxx', name=u'VSD') >>> vsd = NUVSD(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VSD instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsd = NUVSD(id=u'xxxx-xxx-xxx-xxx', name=u'VSD')
>>> vsd = NUVSD(data=my_dict)
"""
super(NUVSD, self).__init__()
# Read/Write Attributes
self._url = None
self._name = None
self._management_ip = None
self._last_state_change = None
self._last_updated_by = None
self._address = None
self._peak_cpuusage = None
self._peak_memory_usage = None
self._peer_addresses = None
self._description = None
self._messages = None
self._disks = None
self._already_marked_for_unavailable = None
self._unavailable_timestamp = None
self._entity_scope = None
self._location = None
self._mode = None
self._product_version = None
self._status = None
self._current_cpuusage = None
self._current_memory_usage = None
self._average_cpuusage = None
self._average_memory_usage = None
self._external_id = None
self.expose_attribute(local_name="url", remote_name="URL", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_state_change", remote_name="lastStateChange", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_cpuusage", remote_name="peakCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peak_memory_usage", remote_name="peakMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="peer_addresses", remote_name="peerAddresses", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="messages", remote_name="messages", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="disks", remote_name="disks", attribute_type=list, is_required=False, is_unique=False)
self.expose_attribute(local_name="already_marked_for_unavailable", remote_name="alreadyMarkedForUnavailable", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="unavailable_timestamp", remote_name="unavailableTimestamp", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="mode", remote_name="mode", attribute_type=str, is_required=False, is_unique=False, choices=[u'CLUSTER', u'STANDALONE'])
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="current_cpuusage", remote_name="currentCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="current_memory_usage", remote_name="currentMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_cpuusage", remote_name="averageCPUUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="average_memory_usage", remote_name="averageMemoryUsage", attribute_type=float, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.jobs = NUJobsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsd_components = NUVSDComponentsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVSDComponent
Represents a VSDComponent in the VSD
Notes: System Monitoring details for components of VSD system.
class NUVSDComponent(NURESTObject):
""" Represents a VSDComponent in the VSD
Notes:
System Monitoring details for components of VSD system.
"""
__rest_name__ = "component"
__resource_name__ = "components"
## Constants
CONST_STATUS_DOWN = "DOWN"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_TYPE_JBOSS = "JBOSS"
CONST_TYPE_EJABBERD = "EJABBERD"
CONST_STATUS_UP = "UP"
CONST_TYPE_MEDIATOR = "MEDIATOR"
CONST_TYPE_TCA = "TCA"
CONST_STATUS_ADMIN_DOWN = "ADMIN_DOWN"
CONST_TYPE_STATSSERVER = "STATSSERVER"
CONST_TYPE_STATSCOLLECTOR = "STATSCOLLECTOR"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_TYPE_PERCONA = "PERCONA"
def __init__(self, **kwargs):
""" Initializes a VSDComponent instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsdcomponent = NUVSDComponent(id=u'xxxx-xxx-xxx-xxx', name=u'VSDComponent')
>>> vsdcomponent = NUVSDComponent(data=my_dict)
"""
super(NUVSDComponent, self).__init__()
# Read/Write Attributes
self._name = None
self._management_ip = None
self._address = None
self._description = None
self._entity_scope = None
self._location = None
self._product_version = None
self._status = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False, choices=[u'EJABBERD', u'JBOSS', u'MEDIATOR', u'PERCONA', u'STATSCOLLECTOR', u'STATSSERVER', u'TCA'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Identifies the entity with a name.
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Identifies the entity with a name.
"""
self._name = value
@property
def management_ip(self):
""" Get management_ip value.
Notes:
An optional management IP to log into this component.
This attribute is named `managementIP` in VSD API.
"""
return self._management_ip
@management_ip.setter
def management_ip(self, value):
""" Set management_ip value.
Notes:
An optional management IP to log into this component.
This attribute is named `managementIP` in VSD API.
"""
self._management_ip = value
@property
def address(self):
""" Get address value.
Notes:
An optional IP to access this component.
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
An optional IP to access this component.
"""
self._address = value
@property
def description(self):
""" Get description value.
Notes:
Description of the entity.
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the entity.
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location(self):
""" Get location value.
Notes:
Identifies the entity to be associated with a location.
"""
return self._location
@location.setter
def location(self, value):
""" Set location value.
Notes:
Identifies the entity to be associated with a location.
"""
self._location = value
@property
def product_version(self):
""" Get product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
return self._product_version
@product_version.setter
def product_version(self, value):
""" Set product_version value.
Notes:
Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
"""
self._product_version = value
@property
def status(self):
""" Get status value.
Notes:
Current status of the entity. Possible values are UP, DOWN, ADMIN_DOWN, .
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Current status of the entity. Possible values are UP, DOWN, ADMIN_DOWN, .
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def type(self):
""" Get type value.
Notes:
Type of the component.
"""
return self._type
@type.setter
def type(self, value):
""" Set type value.
Notes:
Type of the component.
"""
self._type = value
Ancestors (in MRO)
- NUVSDComponent
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_STATUS_ADMIN_DOWN
var CONST_STATUS_DOWN
var CONST_STATUS_UP
var CONST_TYPE_EJABBERD
var CONST_TYPE_JBOSS
var CONST_TYPE_MEDIATOR
var CONST_TYPE_PERCONA
var CONST_TYPE_STATSCOLLECTOR
var CONST_TYPE_STATSSERVER
var CONST_TYPE_TCA
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: An optional IP to access this component.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the entity.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_date
Get last update date
var local_id
Get local id
var location
Get location value.
Notes: Identifies the entity to be associated with a location.
var management_ip
Get management_ip value.
Notes: An optional management IP to log into this component.
This attribute is named `managementIP` in VSD API.
var metadatas
var name
Get name value.
Notes: Identifies the entity with a name.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var product_version
Get product_version value.
Notes: Product version supported by this entity.
This attribute is named `productVersion` in VSD API.
var status
Get status value.
Notes: Current status of the entity. Possible values are UP, DOWN, ADMIN_DOWN, .
var type
Get type value.
Notes: Type of the component.
Methods
def __init__(
self, **kwargs)
Initializes a VSDComponent instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vsdcomponent = NUVSDComponent(id=u'xxxx-xxx-xxx-xxx', name=u'VSDComponent') >>> vsdcomponent = NUVSDComponent(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VSDComponent instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsdcomponent = NUVSDComponent(id=u'xxxx-xxx-xxx-xxx', name=u'VSDComponent')
>>> vsdcomponent = NUVSDComponent(data=my_dict)
"""
super(NUVSDComponent, self).__init__()
# Read/Write Attributes
self._name = None
self._management_ip = None
self._address = None
self._description = None
self._entity_scope = None
self._location = None
self._product_version = None
self._status = None
self._external_id = None
self._type = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="management_ip", remote_name="managementIP", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'ADMIN_DOWN', u'DOWN', u'UP'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="type", remote_name="type", attribute_type=str, is_required=False, is_unique=False, choices=[u'EJABBERD', u'JBOSS', u'MEDIATOR', u'PERCONA', u'STATSCOLLECTOR', u'STATSSERVER', u'TCA'])
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVSDSession
VSD User Session
Session can be started and stopped whenever its needed
class NUVSDSession(NURESTSession):
""" VSD User Session
Session can be started and stopped whenever its needed
"""
def __init__(self, username, enterprise, api_url, password=None, certificate=None):
""" Initializes a new sesssion
Args:
username (string): the username
password (string): the password
enterprise (string): the enterprise
api_url (string): the url to the api
Example:
>>> session = NUvsdSession(username="csproot", password="csproot", enterprise="csp", api_url="https://VSD:8443")
>>> session.start()
"""
if certificate is None and password is None:
raise InternalConsitencyError('NUvsdSession needs either a password or a certificate')
super(NUVSDSession, self).__init__(username=username, password=password, enterprise=enterprise, api_url=api_url, api_prefix="nuage/api", version=str(self.version), certificate=certificate)
@property
def version(self):
""" Returns the current VSD version
"""
return 3.2
@property
def me(self):
""" Returns the root object
"""
return self.root_object
@classmethod
def create_root_object(self):
""" Returns a new instance
"""
return NUMe()
## Custom methods
@property
def user(self):
return self.root_object
Ancestors (in MRO)
- NUVSDSession
- bambou.nurest_session.NURESTSession
- __builtin__.object
Instance variables
var is_impersonating
Returns True if the session is currently impersonating a root object
Returns: (bool): a boolean that indicate if the session is impersonating a root object
var login_controller
Returns the :class:bambou.NURESTLoginController of the current session
Note: You should not need to use this method. It's used automatically when needed
var me
Returns the root object
var push_center
Returns the :class:bambou.NURESTPushCenter of the current session
Note: Use this method to start and stop receiving push notifications
var root_object
Returns the root object of the session
Returns: (bambou.NURESTRootObject): the root object
var user
var version
Returns the current VSD version
Methods
def __init__(
self, username, enterprise, api_url, password=None, certificate=None)
Initializes a new sesssion
Args: username (string): the username password (string): the password enterprise (string): the enterprise api_url (string): the url to the api
Example: >>> session = NUvsdSession(username="csproot", password="csproot", enterprise="csp", api_url="https://VSD:8443") >>> session.start()
def __init__(self, username, enterprise, api_url, password=None, certificate=None):
""" Initializes a new sesssion
Args:
username (string): the username
password (string): the password
enterprise (string): the enterprise
api_url (string): the url to the api
Example:
>>> session = NUvsdSession(username="csproot", password="csproot", enterprise="csp", api_url="https://VSD:8443")
>>> session.start()
"""
if certificate is None and password is None:
raise InternalConsitencyError('NUvsdSession needs either a password or a certificate')
super(NUVSDSession, self).__init__(username=username, password=password, enterprise=enterprise, api_url=api_url, api_prefix="nuage/api", version=str(self.version), certificate=certificate)
def create_root_object(
self)
Returns a new instance
@classmethod
def create_root_object(self):
""" Returns a new instance
"""
return NUMe()
def equals(
self, session)
Verify if the current session equals the given parameter
Notes: Verification is based on username, enterprise, api_url and its version.
Args: session(bambou.NURESTSession): the session to compare with
Returns: (bool): True if session are equal
def equals(self, session):
""" Verify if the current session equals the given parameter
Notes:
Verification is based on username, enterprise, api_url and its version.
Args:
session(bambou.NURESTSession): the session to compare with
Returns:
(bool): True if session are equal
"""
return self.login_controller.equals(session.login_controller)
def get_current_session(
cls)
Get the current session
Returns: (bambou.NURESTSession): the current session
@classmethod
def get_current_session(cls):
"""
Get the current session
Returns:
(bambou.NURESTSession): the current session
"""
return _NURESTSessionCurrentContext.session
def impersonate(
self, username, enterprise)
Change the session to impersonate a user within an enterprise
Args: username (string): name of the user to impersonate enterprise (string): name of the enterprise
def impersonate(self, username, enterprise):
"""
Change the session to impersonate a user within an enterprise
Args:
username (string): name of the user to impersonate
enterprise (string): name of the enterprise
"""
self._login_controller.impersonate(username, enterprise)
def is_current_session(
self)
Verify if the session is the current.
Returns: (bool): True if the session is the current
def is_current_session(self):
""" Verify if the session is the current.
Returns:
(bool): True if the session is the current
"""
current_session = NURESTSession.get_current_session()
return current_session and self.equals(current_session)
def reset(
self)
Resets the session.
Resetting the session will flush the API stored API key. Any additional calls will require to call start, and a /me request will be reissued.
def reset(self):
"""
Resets the session.
Resetting the session will flush the API stored API key. Any additional calls will require to call start, and a
/me request will be reissued.
"""
self._root_object = None
self.login_controller.api_key = None
def start(
self)
Starts the session.
Starting the session will actually get the API key of the current user
def start(self):
"""
Starts the session.
Starting the session will actually get the API key of the current user
"""
try:
frame = inspect.stack()[1][0]
except IndexError:
_NURESTSessionCurrentContext.session = self
self._authenticate()
return self
if self._in_with_statement(frame):
return _NURESTSessionContext.new(self)
else:
_NURESTSessionCurrentContext.session = self
self._authenticate()
return self
def stop_impersonate(
self)
Stop impersonating a user
def stop_impersonate(self):
"""
Stop impersonating a user
"""
self._login_controller.stop_impersonate()
class NUVSP
Represents a VSP in the VSD
Notes: System Monitoring details for VSP.
class NUVSP(NURESTObject):
""" Represents a VSP in the VSD
Notes:
System Monitoring details for VSP.
"""
__rest_name__ = "vsp"
__resource_name__ = "vsps"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VSP instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsp = NUVSP(id=u'xxxx-xxx-xxx-xxx', name=u'VSP')
>>> vsp = NUVSP(data=my_dict)
"""
super(NUVSP, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._location = None
self._product_version = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.hscs = NUHSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vscs = NUVSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsds = NUVSDsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def name(self):
""" Get name value.
Notes:
Name of the VSP
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the VSP
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def description(self):
""" Get description value.
Notes:
Description of the VSP
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
Description of the VSP
"""
self._description = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def location(self):
""" Get location value.
Notes:
Installed location of the VSP product
"""
return self._location
@location.setter
def location(self, value):
""" Set location value.
Notes:
Installed location of the VSP product
"""
self._location = value
@property
def product_version(self):
""" Get product_version value.
Notes:
Product version number for VSP
This attribute is named `productVersion` in VSD API.
"""
return self._product_version
@product_version.setter
def product_version(self, value):
""" Set product_version value.
Notes:
Product version number for VSP
This attribute is named `productVersion` in VSD API.
"""
self._product_version = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVSP
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: Description of the VSP
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var hscs
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var location
Get location value.
Notes: Installed location of the VSP product
var metadatas
var name
Get name value.
Notes: Name of the VSP
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var product_version
Get product_version value.
Notes: Product version number for VSP
This attribute is named `productVersion` in VSD API.
var vscs
var vsds
Methods
def __init__(
self, **kwargs)
Initializes a VSP instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vsp = NUVSP(id=u'xxxx-xxx-xxx-xxx', name=u'VSP') >>> vsp = NUVSP(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VSP instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsp = NUVSP(id=u'xxxx-xxx-xxx-xxx', name=u'VSP')
>>> vsp = NUVSP(data=my_dict)
"""
super(NUVSP, self).__init__()
# Read/Write Attributes
self._name = None
self._last_updated_by = None
self._description = None
self._entity_scope = None
self._location = None
self._product_version = None
self._external_id = None
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="location", remote_name="location", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="product_version", remote_name="productVersion", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.hscs = NUHSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vscs = NUVSCsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vsds = NUVSDsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVirtualIP
Represents a VirtualIP in the VSD
Notes: Virtual IP address.
class NUVirtualIP(NURESTObject):
""" Represents a VirtualIP in the VSD
Notes:
Virtual IP address.
"""
__rest_name__ = "virtualip"
__resource_name__ = "virtualips"
## Constants
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
def __init__(self, **kwargs):
""" Initializes a VirtualIP instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> virtualip = NUVirtualIP(id=u'xxxx-xxx-xxx-xxx', name=u'VirtualIP')
>>> virtualip = NUVirtualIP(data=my_dict)
"""
super(NUVirtualIP, self).__init__()
# Read/Write Attributes
self._mac = None
self._last_updated_by = None
self._virtual_ip = None
self._entity_scope = None
self._associated_floating_ip_id = None
self._subnet_id = None
self._external_id = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="virtual_ip", remote_name="virtualIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_floating_ip_id", remote_name="associatedFloatingIPID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subnet_id", remote_name="subnetID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def mac(self):
""" Get mac value.
Notes:
The MAC address of the virtual port
This attribute is named `MAC` in VSD API.
"""
return self._mac
@mac.setter
def mac(self, value):
""" Set mac value.
Notes:
The MAC address of the virtual port
This attribute is named `MAC` in VSD API.
"""
self._mac = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def virtual_ip(self):
""" Get virtual_ip value.
Notes:
Virtual IP address
This attribute is named `virtualIP` in VSD API.
"""
return self._virtual_ip
@virtual_ip.setter
def virtual_ip(self, value):
""" Set virtual_ip value.
Notes:
Virtual IP address
This attribute is named `virtualIP` in VSD API.
"""
self._virtual_ip = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_floating_ip_id(self):
""" Get associated_floating_ip_id value.
Notes:
Id of Floating IP address associated to this virtual ip
This attribute is named `associatedFloatingIPID` in VSD API.
"""
return self._associated_floating_ip_id
@associated_floating_ip_id.setter
def associated_floating_ip_id(self, value):
""" Set associated_floating_ip_id value.
Notes:
Id of Floating IP address associated to this virtual ip
This attribute is named `associatedFloatingIPID` in VSD API.
"""
self._associated_floating_ip_id = value
@property
def subnet_id(self):
""" Get subnet_id value.
Notes:
Id of subnet to which this ip address belongs
This attribute is named `subnetID` in VSD API.
"""
return self._subnet_id
@subnet_id.setter
def subnet_id(self, value):
""" Set subnet_id value.
Notes:
Id of subnet to which this ip address belongs
This attribute is named `subnetID` in VSD API.
"""
self._subnet_id = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVirtualIP
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var resource_name
var rest_name
Instance variables
var associated_floating_ip_id
Get associated_floating_ip_id value.
Notes: Id of Floating IP address associated to this virtual ip
This attribute is named `associatedFloatingIPID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var mac
Get mac value.
Notes: The MAC address of the virtual port
This attribute is named `MAC` in VSD API.
var metadatas
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var subnet_id
Get subnet_id value.
Notes: Id of subnet to which this ip address belongs
This attribute is named `subnetID` in VSD API.
var virtual_ip
Get virtual_ip value.
Notes: Virtual IP address
This attribute is named `virtualIP` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a VirtualIP instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> virtualip = NUVirtualIP(id=u'xxxx-xxx-xxx-xxx', name=u'VirtualIP') >>> virtualip = NUVirtualIP(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VirtualIP instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> virtualip = NUVirtualIP(id=u'xxxx-xxx-xxx-xxx', name=u'VirtualIP')
>>> virtualip = NUVirtualIP(data=my_dict)
"""
super(NUVirtualIP, self).__init__()
# Read/Write Attributes
self._mac = None
self._last_updated_by = None
self._virtual_ip = None
self._entity_scope = None
self._associated_floating_ip_id = None
self._subnet_id = None
self._external_id = None
self.expose_attribute(local_name="mac", remote_name="MAC", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="virtual_ip", remote_name="virtualIP", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_floating_ip_id", remote_name="associatedFloatingIPID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="subnet_id", remote_name="subnetID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUVsgRedundantPort
Represents a VsgRedundantPort in the VSD
Notes: Represents a redundant Port under a particular gateway object or redundant group object.
class NUVsgRedundantPort(NURESTObject):
""" Represents a VsgRedundantPort in the VSD
Notes:
Represents a redundant Port under a particular gateway object or redundant group object.
"""
__rest_name__ = "vsgredundantport"
__resource_name__ = "vsgredundantports"
## Constants
CONST_PORT_TYPE_NETWORK = "NETWORK"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_STATUS_READY = "READY"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_STATUS_INITIALIZED = "INITIALIZED"
CONST_STATUS_MISMATCH = "MISMATCH"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_PORT_TYPE_ACCESS = "ACCESS"
CONST_STATUS_ORPHAN = "ORPHAN"
def __init__(self, **kwargs):
""" Initializes a VsgRedundantPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsgredundantport = NUVsgRedundantPort(id=u'xxxx-xxx-xxx-xxx', name=u'VsgRedundantPort')
>>> vsgredundantport = NUVsgRedundantPort(data=my_dict)
"""
super(NUVsgRedundantPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._entity_scope = None
self._port_peer1_id = None
self._port_peer2_id = None
self._port_type = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_peer1_id", remote_name="portPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_peer2_id", remote_name="portPeer2ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def vlan_range(self):
""" Get vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
return self._vlan_range
@vlan_range.setter
def vlan_range(self, value):
""" Set vlan_range value.
Notes:
VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
"""
self._vlan_range = value
@property
def name(self):
""" Get name value.
Notes:
Name of the Port
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the Port
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Port
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Port
"""
self._description = value
@property
def physical_name(self):
""" Get physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
return self._physical_name
@physical_name.setter
def physical_name(self, value):
""" Set physical_name value.
Notes:
Identifier of the Port
This attribute is named `physicalName` in VSD API.
"""
self._physical_name = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def port_peer1_id(self):
""" Get port_peer1_id value.
Notes:
The master gateway peer port id.
This attribute is named `portPeer1ID` in VSD API.
"""
return self._port_peer1_id
@port_peer1_id.setter
def port_peer1_id(self, value):
""" Set port_peer1_id value.
Notes:
The master gateway peer port id.
This attribute is named `portPeer1ID` in VSD API.
"""
self._port_peer1_id = value
@property
def port_peer2_id(self):
""" Get port_peer2_id value.
Notes:
The slave gateway peer port id.
This attribute is named `portPeer2ID` in VSD API.
"""
return self._port_peer2_id
@port_peer2_id.setter
def port_peer2_id(self, value):
""" Set port_peer2_id value.
Notes:
The slave gateway peer port id.
This attribute is named `portPeer2ID` in VSD API.
"""
self._port_peer2_id = value
@property
def port_type(self):
""" Get port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
return self._port_type
@port_type.setter
def port_type(self, value):
""" Set port_type value.
Notes:
Type of the Port.
This attribute is named `portType` in VSD API.
"""
self._port_type = value
@property
def use_user_mnemonic(self):
""" Get use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
return self._use_user_mnemonic
@use_user_mnemonic.setter
def use_user_mnemonic(self, value):
""" Set use_user_mnemonic value.
Notes:
determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
"""
self._use_user_mnemonic = value
@property
def user_mnemonic(self):
""" Get user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
return self._user_mnemonic
@user_mnemonic.setter
def user_mnemonic(self, value):
""" Set user_mnemonic value.
Notes:
user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
"""
self._user_mnemonic = value
@property
def associated_egress_qos_policy_id(self):
""" Get associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
return self._associated_egress_qos_policy_id
@associated_egress_qos_policy_id.setter
def associated_egress_qos_policy_id(self, value):
""" Set associated_egress_qos_policy_id value.
Notes:
ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
"""
self._associated_egress_qos_policy_id = value
@property
def status(self):
""" Get status value.
Notes:
Status of the port.
"""
return self._status
@status.setter
def status(self, value):
""" Set status value.
Notes:
Status of the port.
"""
self._status = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
Ancestors (in MRO)
- NUVsgRedundantPort
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_PORT_TYPE_ACCESS
var CONST_PORT_TYPE_NETWORK
var CONST_STATUS_INITIALIZED
var CONST_STATUS_MISMATCH
var CONST_STATUS_ORPHAN
var CONST_STATUS_READY
var resource_name
var rest_name
Instance variables
var alarms
var associated_egress_qos_policy_id
Get associated_egress_qos_policy_id value.
Notes: ID of the Egress QOS Policy associated with this Vlan.
This attribute is named `associatedEgressQOSPolicyID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Port
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the Port
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var physical_name
Get physical_name value.
Notes: Identifier of the Port
This attribute is named `physicalName` in VSD API.
var port_peer1_id
Get port_peer1_id value.
Notes: The master gateway peer port id.
This attribute is named `portPeer1ID` in VSD API.
var port_peer2_id
Get port_peer2_id value.
Notes: The slave gateway peer port id.
This attribute is named `portPeer2ID` in VSD API.
var port_type
Get port_type value.
Notes: Type of the Port.
This attribute is named `portType` in VSD API.
var status
Get status value.
Notes: Status of the port.
var use_user_mnemonic
Get use_user_mnemonic value.
Notes: determines whether to use user mnemonic of the Port
This attribute is named `useUserMnemonic` in VSD API.
var user_mnemonic
Get user_mnemonic value.
Notes: user mnemonic of the Port
This attribute is named `userMnemonic` in VSD API.
var vlan_range
Get vlan_range value.
Notes: VLAN Range of the Port. Format must conform to a-b,c,d-f where a,b,c,d,f are integers between 0 and 4095.
This attribute is named `VLANRange` in VSD API.
var vlans
Methods
def __init__(
self, **kwargs)
Initializes a VsgRedundantPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> vsgredundantport = NUVsgRedundantPort(id=u'xxxx-xxx-xxx-xxx', name=u'VsgRedundantPort') >>> vsgredundantport = NUVsgRedundantPort(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a VsgRedundantPort instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> vsgredundantport = NUVsgRedundantPort(id=u'xxxx-xxx-xxx-xxx', name=u'VsgRedundantPort')
>>> vsgredundantport = NUVsgRedundantPort(data=my_dict)
"""
super(NUVsgRedundantPort, self).__init__()
# Read/Write Attributes
self._vlan_range = None
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._description = None
self._physical_name = None
self._entity_scope = None
self._port_peer1_id = None
self._port_peer2_id = None
self._port_type = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_egress_qos_policy_id = None
self._status = None
self._external_id = None
self.expose_attribute(local_name="vlan_range", remote_name="VLANRange", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="physical_name", remote_name="physicalName", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="port_peer1_id", remote_name="portPeer1ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_peer2_id", remote_name="portPeer2ID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="port_type", remote_name="portType", attribute_type=str, is_required=True, is_unique=False, choices=[u'ACCESS', u'NETWORK'])
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_egress_qos_policy_id", remote_name="associatedEgressQOSPolicyID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="status", remote_name="status", attribute_type=str, is_required=False, is_unique=False, choices=[u'INITIALIZED', u'MISMATCH', u'ORPHAN', u'READY'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vlans = NUVLANsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUWANService
Represents a WANService in the VSD
Notes: Represents a WAN Service Object.
class NUWANService(NURESTObject):
""" Represents a WANService in the VSD
Notes:
Represents a WAN Service Object.
"""
__rest_name__ = "service"
__resource_name__ = "services"
## Constants
CONST_TUNNEL_TYPE_DC_DEFAULT = "DC_DEFAULT"
CONST_PERMITTED_ACTION_USE = "USE"
CONST_SERVICE_TYPE_L2 = "L2"
CONST_SERVICE_TYPE_L3 = "L3"
CONST_PERMITTED_ACTION_READ = "READ"
CONST_TUNNEL_TYPE_VXLAN = "VXLAN"
CONST_CONFIG_TYPE_STATIC = "STATIC"
CONST_PERMITTED_ACTION_ALL = "ALL"
CONST_PERMITTED_ACTION_DEPLOY = "DEPLOY"
CONST_PERMITTED_ACTION_EXTEND = "EXTEND"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_PERMITTED_ACTION_INSTANTIATE = "INSTANTIATE"
CONST_CONFIG_TYPE_DYNAMIC = "DYNAMIC"
CONST_TUNNEL_TYPE_GRE = "GRE"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
def __init__(self, **kwargs):
""" Initializes a WANService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> wanservice = NUWANService(id=u'xxxx-xxx-xxx-xxx', name=u'WANService')
>>> wanservice = NUWANService(data=my_dict)
"""
super(NUWANService, self).__init__()
# Read/Write Attributes
self._wan_service_identifier = None
self._irb_enabled = None
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._service_policy = None
self._service_type = None
self._description = None
self._vn_id = None
self._enterprise_name = None
self._entity_scope = None
self._domain_name = None
self._config_type = None
self._orphan = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_domain_id = None
self._associated_vpn_connect_id = None
self._tunnel_type = None
self._external_id = None
self._external_route_target = None
self.expose_attribute(local_name="wan_service_identifier", remote_name="WANServiceIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="irb_enabled", remote_name="IRBEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="service_policy", remote_name="servicePolicy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_type", remote_name="serviceType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L2', u'L3'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vn_id", remote_name="vnId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_name", remote_name="enterpriseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="config_type", remote_name="configType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DYNAMIC', u'STATIC'])
self.expose_attribute(local_name="orphan", remote_name="orphan", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_domain_id", remote_name="associatedDomainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vpn_connect_id", remote_name="associatedVPNConnectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tunnel_type", remote_name="tunnelType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC_DEFAULT', u'GRE', u'VXLAN'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="external_route_target", remote_name="externalRouteTarget", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def wan_service_identifier(self):
""" Get wan_service_identifier value.
Notes:
Identifier of the WAN Service
This attribute is named `WANServiceIdentifier` in VSD API.
"""
return self._wan_service_identifier
@wan_service_identifier.setter
def wan_service_identifier(self, value):
""" Set wan_service_identifier value.
Notes:
Identifier of the WAN Service
This attribute is named `WANServiceIdentifier` in VSD API.
"""
self._wan_service_identifier = value
@property
def irb_enabled(self):
""" Get irb_enabled value.
Notes:
Determines whether Integrated Routing and Bridging is enabled on the WAN Service
This attribute is named `IRBEnabled` in VSD API.
"""
return self._irb_enabled
@irb_enabled.setter
def irb_enabled(self, value):
""" Set irb_enabled value.
Notes:
Determines whether Integrated Routing and Bridging is enabled on the WAN Service
This attribute is named `IRBEnabled` in VSD API.
"""
self._irb_enabled = value
@property
def name(self):
""" Get name value.
Notes:
Name of the WAN Service
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the WAN Service
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def permitted_action(self):
""" Get permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
return self._permitted_action
@permitted_action.setter
def permitted_action(self, value):
""" Set permitted_action value.
Notes:
The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
"""
self._permitted_action = value
@property
def service_policy(self):
""" Get service_policy value.
Notes:
Name of 7X50 Policy associated with the service
This attribute is named `servicePolicy` in VSD API.
"""
return self._service_policy
@service_policy.setter
def service_policy(self, value):
""" Set service_policy value.
Notes:
Name of 7X50 Policy associated with the service
This attribute is named `servicePolicy` in VSD API.
"""
self._service_policy = value
@property
def service_type(self):
""" Get service_type value.
Notes:
Type of the service.
This attribute is named `serviceType` in VSD API.
"""
return self._service_type
@service_type.setter
def service_type(self, value):
""" Set service_type value.
Notes:
Type of the service.
This attribute is named `serviceType` in VSD API.
"""
self._service_type = value
@property
def description(self):
""" Get description value.
Notes:
A description of the WAN Service
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the WAN Service
"""
self._description = value
@property
def vn_id(self):
""" Get vn_id value.
Notes:
VNID of the BackHaul Subnet of L3Domain /L2Domain to which this WANService is associated
This attribute is named `vnId` in VSD API.
"""
return self._vn_id
@vn_id.setter
def vn_id(self, value):
""" Set vn_id value.
Notes:
VNID of the BackHaul Subnet of L3Domain /L2Domain to which this WANService is associated
This attribute is named `vnId` in VSD API.
"""
self._vn_id = value
@property
def enterprise_name(self):
""" Get enterprise_name value.
Notes:
The associated enterprise name.
This attribute is named `enterpriseName` in VSD API.
"""
return self._enterprise_name
@enterprise_name.setter
def enterprise_name(self, value):
""" Set enterprise_name value.
Notes:
The associated enterprise name.
This attribute is named `enterpriseName` in VSD API.
"""
self._enterprise_name = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def domain_name(self):
""" Get domain_name value.
Notes:
The associated domain name.
This attribute is named `domainName` in VSD API.
"""
return self._domain_name
@domain_name.setter
def domain_name(self, value):
""" Set domain_name value.
Notes:
The associated domain name.
This attribute is named `domainName` in VSD API.
"""
self._domain_name = value
@property
def config_type(self):
""" Get config_type value.
Notes:
Type of the CONFIG.
This attribute is named `configType` in VSD API.
"""
return self._config_type
@config_type.setter
def config_type(self, value):
""" Set config_type value.
Notes:
Type of the CONFIG.
This attribute is named `configType` in VSD API.
"""
self._config_type = value
@property
def orphan(self):
""" Get orphan value.
Notes:
Indicates if this WAN Service is orphan or not.
"""
return self._orphan
@orphan.setter
def orphan(self, value):
""" Set orphan value.
Notes:
Indicates if this WAN Service is orphan or not.
"""
self._orphan = value
@property
def use_user_mnemonic(self):
""" Get use_user_mnemonic value.
Notes:
Determines whether to use user mnemonic of the WAN Service
This attribute is named `useUserMnemonic` in VSD API.
"""
return self._use_user_mnemonic
@use_user_mnemonic.setter
def use_user_mnemonic(self, value):
""" Set use_user_mnemonic value.
Notes:
Determines whether to use user mnemonic of the WAN Service
This attribute is named `useUserMnemonic` in VSD API.
"""
self._use_user_mnemonic = value
@property
def user_mnemonic(self):
""" Get user_mnemonic value.
Notes:
user mnemonic of the WAN Service
This attribute is named `userMnemonic` in VSD API.
"""
return self._user_mnemonic
@user_mnemonic.setter
def user_mnemonic(self, value):
""" Set user_mnemonic value.
Notes:
user mnemonic of the WAN Service
This attribute is named `userMnemonic` in VSD API.
"""
self._user_mnemonic = value
@property
def associated_domain_id(self):
""" Get associated_domain_id value.
Notes:
ID of the entity to which the WAN Service is attached to. This could be ID DOMAIN/L2DOMAIN
This attribute is named `associatedDomainID` in VSD API.
"""
return self._associated_domain_id
@associated_domain_id.setter
def associated_domain_id(self, value):
""" Set associated_domain_id value.
Notes:
ID of the entity to which the WAN Service is attached to. This could be ID DOMAIN/L2DOMAIN
This attribute is named `associatedDomainID` in VSD API.
"""
self._associated_domain_id = value
@property
def associated_vpn_connect_id(self):
""" Get associated_vpn_connect_id value.
Notes:
The associated vpn connect ID.
This attribute is named `associatedVPNConnectID` in VSD API.
"""
return self._associated_vpn_connect_id
@associated_vpn_connect_id.setter
def associated_vpn_connect_id(self, value):
""" Set associated_vpn_connect_id value.
Notes:
The associated vpn connect ID.
This attribute is named `associatedVPNConnectID` in VSD API.
"""
self._associated_vpn_connect_id = value
@property
def tunnel_type(self):
""" Get tunnel_type value.
Notes:
Type of the tunnel.
This attribute is named `tunnelType` in VSD API.
"""
return self._tunnel_type
@tunnel_type.setter
def tunnel_type(self, value):
""" Set tunnel_type value.
Notes:
Type of the tunnel.
This attribute is named `tunnelType` in VSD API.
"""
self._tunnel_type = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
@property
def external_route_target(self):
""" Get external_route_target value.
Notes:
Route target associated with the WAN. It is an optional parameterthat can be provided by the user
This attribute is named `externalRouteTarget` in VSD API.
"""
return self._external_route_target
@external_route_target.setter
def external_route_target(self, value):
""" Set external_route_target value.
Notes:
Route target associated with the WAN. It is an optional parameterthat can be provided by the user
This attribute is named `externalRouteTarget` in VSD API.
"""
self._external_route_target = value
Ancestors (in MRO)
- NUWANService
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_CONFIG_TYPE_DYNAMIC
var CONST_CONFIG_TYPE_STATIC
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_PERMITTED_ACTION_ALL
var CONST_PERMITTED_ACTION_DEPLOY
var CONST_PERMITTED_ACTION_EXTEND
var CONST_PERMITTED_ACTION_INSTANTIATE
var CONST_PERMITTED_ACTION_READ
var CONST_PERMITTED_ACTION_USE
var CONST_SERVICE_TYPE_L2
var CONST_SERVICE_TYPE_L3
var CONST_TUNNEL_TYPE_DC_DEFAULT
var CONST_TUNNEL_TYPE_GRE
var CONST_TUNNEL_TYPE_VXLAN
var resource_name
var rest_name
Instance variables
var alarms
var associated_domain_id
Get associated_domain_id value.
Notes: ID of the entity to which the WAN Service is attached to. This could be ID DOMAIN/L2DOMAIN
This attribute is named `associatedDomainID` in VSD API.
var associated_vpn_connect_id
Get associated_vpn_connect_id value.
Notes: The associated vpn connect ID.
This attribute is named `associatedVPNConnectID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var config_type
Get config_type value.
Notes: Type of the CONFIG.
This attribute is named `configType` in VSD API.
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the WAN Service
var domain_name
Get domain_name value.
Notes: The associated domain name.
This attribute is named `domainName` in VSD API.
var enterprise_name
Get enterprise_name value.
Notes: The associated enterprise name.
This attribute is named `enterpriseName` in VSD API.
var enterprise_permissions
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var external_route_target
Get external_route_target value.
Notes: Route target associated with the WAN. It is an optional parameterthat can be provided by the user
This attribute is named `externalRouteTarget` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var irb_enabled
Get irb_enabled value.
Notes: Determines whether Integrated Routing and Bridging is enabled on the WAN Service
This attribute is named `IRBEnabled` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var name
Get name value.
Notes: Name of the WAN Service
var orphan
Get orphan value.
Notes: Indicates if this WAN Service is orphan or not.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var permitted_action
Get permitted_action value.
Notes: The permitted action to USE/EXTEND this Gateway.
This attribute is named `permittedAction` in VSD API.
var service_policy
Get service_policy value.
Notes: Name of 7X50 Policy associated with the service
This attribute is named `servicePolicy` in VSD API.
var service_type
Get service_type value.
Notes: Type of the service.
This attribute is named `serviceType` in VSD API.
var tunnel_type
Get tunnel_type value.
Notes: Type of the tunnel.
This attribute is named `tunnelType` in VSD API.
var use_user_mnemonic
Get use_user_mnemonic value.
Notes: Determines whether to use user mnemonic of the WAN Service
This attribute is named `useUserMnemonic` in VSD API.
var user_mnemonic
Get user_mnemonic value.
Notes: user mnemonic of the WAN Service
This attribute is named `userMnemonic` in VSD API.
var vn_id
Get vn_id value.
Notes: VNID of the BackHaul Subnet of L3Domain /L2Domain to which this WANService is associated
This attribute is named `vnId` in VSD API.
var wan_service_identifier
Get wan_service_identifier value.
Notes: Identifier of the WAN Service
This attribute is named `WANServiceIdentifier` in VSD API.
Methods
def __init__(
self, **kwargs)
Initializes a WANService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> wanservice = NUWANService(id=u'xxxx-xxx-xxx-xxx', name=u'WANService') >>> wanservice = NUWANService(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a WANService instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> wanservice = NUWANService(id=u'xxxx-xxx-xxx-xxx', name=u'WANService')
>>> wanservice = NUWANService(data=my_dict)
"""
super(NUWANService, self).__init__()
# Read/Write Attributes
self._wan_service_identifier = None
self._irb_enabled = None
self._name = None
self._last_updated_by = None
self._permitted_action = None
self._service_policy = None
self._service_type = None
self._description = None
self._vn_id = None
self._enterprise_name = None
self._entity_scope = None
self._domain_name = None
self._config_type = None
self._orphan = None
self._use_user_mnemonic = None
self._user_mnemonic = None
self._associated_domain_id = None
self._associated_vpn_connect_id = None
self._tunnel_type = None
self._external_id = None
self._external_route_target = None
self.expose_attribute(local_name="wan_service_identifier", remote_name="WANServiceIdentifier", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="irb_enabled", remote_name="IRBEnabled", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="permitted_action", remote_name="permittedAction", attribute_type=str, is_required=False, is_unique=False, choices=[u'ALL', u'DEPLOY', u'EXTEND', u'INSTANTIATE', u'READ', u'USE'])
self.expose_attribute(local_name="service_policy", remote_name="servicePolicy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="service_type", remote_name="serviceType", attribute_type=str, is_required=True, is_unique=False, choices=[u'L2', u'L3'])
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="vn_id", remote_name="vnId", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="enterprise_name", remote_name="enterpriseName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="domain_name", remote_name="domainName", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="config_type", remote_name="configType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DYNAMIC', u'STATIC'])
self.expose_attribute(local_name="orphan", remote_name="orphan", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="use_user_mnemonic", remote_name="useUserMnemonic", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="user_mnemonic", remote_name="userMnemonic", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_domain_id", remote_name="associatedDomainID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_vpn_connect_id", remote_name="associatedVPNConnectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="tunnel_type", remote_name="tunnelType", attribute_type=str, is_required=False, is_unique=False, choices=[u'DC_DEFAULT', u'GRE', u'VXLAN'])
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
self.expose_attribute(local_name="external_route_target", remote_name="externalRouteTarget", attribute_type=str, is_required=False, is_unique=False)
# Fetchers
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.alarms = NUAlarmsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.enterprise_permissions = NUEnterprisePermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUZone
Represents a Zone in the VSD
Notes: The zone is a collection of subnets attached to a domain. The zone concept enables the definition of policies for collections of subnets.
class NUZone(NURESTObject):
""" Represents a Zone in the VSD
Notes:
The zone is a collection of subnets attached to a domain. The zone concept enables the definition of policies for collections of subnets.
"""
__rest_name__ = "zone"
__resource_name__ = "zones"
## Constants
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY = "APPD_FLOW_FORWARDING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION = "MIRROR_DESTINATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER = "KEYSERVER_MEMBER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG = "GATEWAY_SERVICE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT = "VSD_COMPONENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL = "INGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO = "EVPN_BGP_COMMUNITY_TAG_SEQ_NO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP = "SYSTEM_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE = "INFRASTRUCTURE_PORT_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION = "APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG = "ENTERPRISE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE = "VIRTUAL_MACHINE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE = "EGRESS_QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING = "SYSTEM_MONITORING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP = "POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG = "DC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG = "NSPORT_STATIC_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE = "ENTERPRISE_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY = "FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE = "GATEWAY_SECURITY_PROFILE_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER = "VMWARE_VCENTER_CLUSTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE = "CERTIFICATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP = "NETWORK_POLICY_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR = "STATS_COLLECTOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK = "ENTERPRISE_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE = "VPORT_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA = "GATEWAY_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY = "INGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION = "ACLENTRY_LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY = "RTRD_ENTITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE = "ZONE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING = "DSCP_FORWARDING_CLASS_MAPPING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR = "VPORT_MIRROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE = "DOMAIN_FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP = "MC_CHANNEL_MAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA = "ENTERPRISE_SECURED_DATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE = "PORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL = "FLOATINGIP_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE = "BRIDGEINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY = "POLICING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE = "GATEWAY_SECURITY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO = "SERVICE_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE = "INGRESS_ADV_FWD_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP = "GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR = "KEYSERVER_MONITOR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE = "NSGATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP = "GATEWAY_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE = "MC_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP = "BACK_HAUL_SERVICE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST = "GATEWAY_SECURITY_PROFILE_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY = "SUBNET_POOL_ENTRY"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION = "VM_DESCRIPTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER = "APPD_TIER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE = "VM_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR = "EGRESS_QOS_QUEUE_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN = "VLAN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE = "ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE = "EGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR = "EGRESS_QOS_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES = "GEO_VM_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS = "DISKSTATS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP = "VSP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP = "NEXT_HOP_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN = "DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE = "GATEWAY_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD = "INGRESS_ADV_FWD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR = "VMWARE_VCENTER_HYPERVISOR"
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC = "VSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER = "VMWARE_VCENTER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY = "GATEWAY_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ = "SYSTEM_CONFIG_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT = "MULTI_NIC_VPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE = "VMWARE_VRS_ADDRESS_RANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT = "VSG_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG = "INFRASTRUCTURE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE = "LIBVIRT_INTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING = "ENTITY_METADATA_BINDING"
CONST_MAINTENANCE_MODE_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE = "L2DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA = "METADATA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE = "POLICY_GROUP_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP = "DOMAIN_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG = "VMWARE_VCENTER_VRS_BASE_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY = "INGRESS_EXT_SERVICE_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO = "CUSTOMER_VRF_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER = "BGPPEER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO = "RTRD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING = "IP_BINDING"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC = "HSC"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT = "VPORT"
CONST_ENCRYPTION_INHERITED = "INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT = "VIRTUAL_MACHINE_REPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER = "RATE_LIMITER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE = "APPD_EXTERNAL_APP_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE = "INGRESS_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES = "SITE_RES"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION = "KEYSERVER_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY = "DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP = "ENTERPRISE_CONFIG_RESP"
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY = "EVPN_BGP_COMMUNITY_TAG_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE = "FLOATING_IP_ACL_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY = "AUTO_DISC_GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK = "PUBLIC_NETWORK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG = "LDAP_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT = "EXPORTIMPORT"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY = "INGRESS_ADV_FWD_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG = "VMWARE_VCENTER_VRS_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE = "SUBNET_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE = "INFRASTRUCTURE_VSC_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE = "APPD_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE = "NSPORT_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ = "GEO_VM_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD = "UPLINK_RD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION = "NSG_NOTIFICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION = "DHCP_OPTION"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE = "INGRESS_EXT_SERVICE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO = "VPRN_LABEL_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST = "VPORT_MEDIATION_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY = "NSGATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE = "DHCP_ALLOC_MESSAGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY = "SUBNET_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE = "DSCP_FORWARDING_CLASS_TABLE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK = "KEYSERVER_MONITOR_SEK"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER = "USER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG = "EVENT_LOG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP = "NETWORK_MACRO_GROUP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE = "EXTERNAL_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG = "VMWARE_VCENTER_EAM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE = "ZONE_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG = "SYSTEM_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP = "STATIC_ROUTE_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ = "HEALTH_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ = "SITE_REQ"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY = "EGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE = "LICENSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE = "SHARED_RESOURCE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS = "VRS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY = "FLOATINGIP_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST = "MC_LIST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST = "GATEWAY_SECURITY_REQUEST"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT = "NSPORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP = "FLOATINGIP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY = "INGRESS_ADV_FWD_ENTRY"
CONST_MULTICAST_INHERITED = "INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD = "VSD"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE = "DOMAIN_TEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION = "APPD_APPLICATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED = "L2DOMAIN_SHARED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT = "MONITORING_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT = "GEO_VM_EVENT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY = "INGRESS_EXT_SERVICE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM = "CLOUD_MGMT_SYSTEM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL = "PATNATPOOL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG = "GATEWAY_VPORT_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT = "NS_REDUNDANT_PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER = "STATSSERVER"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR = "NODE_EXECUTION_ERROR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE = "INFRASTRUCTURE_GATEWAY_PROFILE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET = "SUBNET"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION = "ENTERPRISE_PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE = "HOSTINTERFACE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED = "KEYSERVER_MONITOR_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT = "PORT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL = "EGRESS_ACL"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP = "BOOTSTRAP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE = "SERVICE_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP = "NSREDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG = "VPORTTAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY = "SHAPING_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO = "RD_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE = "GROUPKEY_ENCRYPTION_PROFILE"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY = "SUBNET_MAC_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP = "DHCP_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP = "VIRTUAL_IP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN = "L2DOMAIN"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY = "APPD_FLOW_SECURITY_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB = "JOB"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP = "GATEWAY_SERVICE_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE = "CHILD_ENTITY_POLICY_CHANGE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE = "SITE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT = "NETWORK_LAYOUT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE = "ADDRESS_RANGE_STATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT = "NETWORK_ELEMENT"
CONST_MAINTENANCE_MODE_DISABLED = "DISABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION = "PERMITTED_ACTION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG = "GATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY = "STATS_POLICY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG = "METADATA_TAG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE = "SERVICES_GATEWAY_RESPONSE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY = "INGRESS_ACL_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION = "BOOTSTRAP_ACTIVATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA = "STATS_TCA"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW = "APPD_FLOW"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE = "VPORT_TAG_BASE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE = "WAN_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM = "ALARM"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG = "NSGATEWAY_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION = "PERMISSION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG = "VMWARE_RELOAD_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP = "GATEWAY_VPORT_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY = "NATMAPENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE = "INGRESS_EXT_SERVICE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG = "DOMAIN_CONFIG"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT = "ENDPOINT"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT = "VPN_CONNECT"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION = "LOCATION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR = "PORT_MR"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY = "EGRESS_ACL_TEMPLATE_ENTRY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED = "KEYSERVER_MONITOR_ENCRYPTED_SEED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS = "STATISTICS"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY = "GATEWAY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP = "PATCONFIG_CONFIG_RESP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO = "VNID_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY = "ENTERPRISE_SECURITY"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO = "ESI_SEQUENCENO"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE = "VLAN_TEMPLATE"
CONST_MAINTENANCE_MODE_ENABLED_INHERITED = "ENABLED_INHERITED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED = "UNSUPPORTED"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE = "QOS_PRIMITIVE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION = "POLICY_DECISION"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP = "REDUNDANT_GW_GRP"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE = "VPORTTAGTEMPLATE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE = "STATIC_ROUTE"
CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER = "VMWARE_VCENTER_DATACENTER"
def __init__(self, **kwargs):
""" Initializes a Zone instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> zone = NUZone(id=u'xxxx-xxx-xxx-xxx', name=u'Zone')
>>> zone = NUZone(data=my_dict)
"""
super(NUZone, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._address = None
self._template_id = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._policy_group_id = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_multicast_channel_map_id = None
self._public_zone = None
self._multicast = None
self._number_of_hosts_in_subnets = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_group_id", remote_name="policyGroupID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_zone", remote_name="publicZone", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="number_of_hosts_in_subnets", remote_name="numberOfHostsInSubnets", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def maintenance_mode(self):
""" Get maintenance_mode value.
Notes:
Indicates if the Zone is accepting VM activation requests.
This attribute is named `maintenanceMode` in VSD API.
"""
return self._maintenance_mode
@maintenance_mode.setter
def maintenance_mode(self, value):
""" Set maintenance_mode value.
Notes:
Indicates if the Zone is accepting VM activation requests.
This attribute is named `maintenanceMode` in VSD API.
"""
self._maintenance_mode = value
@property
def name(self):
""" Get name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
self._address = value
@property
def template_id(self):
""" Get template_id value.
Notes:
The ID of the template that this zone was derived from
This attribute is named `templateID` in VSD API.
"""
return self._template_id
@template_id.setter
def template_id(self, value):
""" Set template_id value.
Notes:
The ID of the template that this zone was derived from
This attribute is named `templateID` in VSD API.
"""
self._template_id = value
@property
def description(self):
""" Get description value.
Notes:
A description of the zone
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the zone
"""
self._description = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet defined
"""
self._netmask = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether or not IPSEC is enabled.
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether or not IPSEC is enabled.
"""
self._encryption = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def policy_group_id(self):
""" Get policy_group_id value.
Notes:
PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
"""
return self._policy_group_id
@policy_group_id.setter
def policy_group_id(self, value):
""" Set policy_group_id value.
Notes:
PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
"""
self._policy_group_id = value
@property
def associated_application_id(self):
""" Get associated_application_id value.
Notes:
The associated application ID.
This attribute is named `associatedApplicationID` in VSD API.
"""
return self._associated_application_id
@associated_application_id.setter
def associated_application_id(self, value):
""" Set associated_application_id value.
Notes:
The associated application ID.
This attribute is named `associatedApplicationID` in VSD API.
"""
self._associated_application_id = value
@property
def associated_application_object_id(self):
""" Get associated_application_object_id value.
Notes:
The associated application object ID.
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
return self._associated_application_object_id
@associated_application_object_id.setter
def associated_application_object_id(self, value):
""" Set associated_application_object_id value.
Notes:
The associated application object ID.
This attribute is named `associatedApplicationObjectID` in VSD API.
"""
self._associated_application_object_id = value
@property
def associated_application_object_type(self):
""" Get associated_application_object_type value.
Notes:
The associated application object type. Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
return self._associated_application_object_type
@associated_application_object_type.setter
def associated_application_object_type(self, value):
""" Set associated_application_object_type value.
Notes:
The associated application object type. Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
"""
self._associated_application_object_type = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this zone/zone template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this zone/zone template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def public_zone(self):
""" Get public_zone value.
Notes:
If a zone is marked as public, then it is lined to the public network associated with this data center
This attribute is named `publicZone` in VSD API.
"""
return self._public_zone
@public_zone.setter
def public_zone(self, value):
""" Set public_zone value.
Notes:
If a zone is marked as public, then it is lined to the public network associated with this data center
This attribute is named `publicZone` in VSD API.
"""
self._public_zone = value
@property
def multicast(self):
""" Get multicast value.
Notes:
Indicates multicast policy on zone.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
Indicates multicast policy on zone.
"""
self._multicast = value
@property
def number_of_hosts_in_subnets(self):
""" Get number_of_hosts_in_subnets value.
Notes:
Number of hosts in each of the subnets that can be created under a zone and are auto-assigned IP addresses
This attribute is named `numberOfHostsInSubnets` in VSD API.
"""
return self._number_of_hosts_in_subnets
@number_of_hosts_in_subnets.setter
def number_of_hosts_in_subnets(self, value):
""" Set number_of_hosts_in_subnets value.
Notes:
Number of hosts in each of the subnets that can be created under a zone and are auto-assigned IP addresses
This attribute is named `numberOfHostsInSubnets` in VSD API.
"""
self._number_of_hosts_in_subnets = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
Ancestors (in MRO)
- NUZone
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ACLENTRY_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ADDRESS_RANGE_STATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ALARM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_EXTERNAL_APP_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_FORWARDING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_FLOW_SECURITY_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPD_TIER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_APPLICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_AUTO_DISC_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BACK_HAUL_SERVICE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BGPPEER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BOOTSTRAP_ACTIVATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_BRIDGEINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CERTIFICATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CHILD_ENTITY_POLICY_CHANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CLOUD_MGMT_SYSTEM
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_CUSTOMER_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_ALLOC_MESSAGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DHCP_OPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DISKSTATS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_MAPPING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_DSCP_FORWARDING_CLASS_TABLE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EGRESS_QOS_QUEUE_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENDPOINT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTERPRISE_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ENTITY_METADATA_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ESI_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVENT_LOG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EVPN_BGP_COMMUNITY_TAG_SEQ_NO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXPORTIMPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_EXTERNAL_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATINGIP_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_FLOATING_IP_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURED_DATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_PROFILE_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SECURITY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_SERVICE_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GATEWAY_VPORT_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_EVENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GEO_VM_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_GROUPKEY_ENCRYPTION_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HEALTH_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HOSTINTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_HSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_GATEWAY_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_PORT_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INFRASTRUCTURE_VSC_PROFILE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ACL_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_ADV_FWD_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_INGRESS_EXT_SERVICE_TEMPLATE_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_IP_BINDING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_JOB
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MEMBER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_ENCRYPTED_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_MONITOR_SEK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_KEYSERVER_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_SHARED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_L2DOMAIN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LDAP_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LIBVIRT_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LICENSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_LOCATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_CHANNEL_MAP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_LIST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MC_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_METADATA_TAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MIRROR_DESTINATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MONITORING_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_MULTI_NIC_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NATMAPENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_ELEMENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_LAYOUT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_MACRO_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NETWORK_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NEXT_HOP_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NODE_EXECUTION_ERROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSGATEWAY_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSG_NOTIFICATION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_STATIC_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSPORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NSREDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_NS_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATCONFIG_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PATNATPOOL
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMISSION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PERMITTED_ACTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_DECISION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_POLICY_GROUP_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_MR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PORT_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_PUBLIC_NETWORK
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_QOS_PRIMITIVE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RATE_LIMITER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_REDUNDANT_GW_GRP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_ENTITY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_RTRD_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICES_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SERVICE_VRF_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHAPING_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SHARED_RESOURCE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SITE_RES
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATIC_ROUTE_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATISTICS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATSSERVER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_COLLECTOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_POLICY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_STATS_TCA
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_MAC_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_POOL_ENTRY
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SUBNET_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_REQ
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_CONFIG_RESP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_SYSTEM_MONITORING
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UNSUPPORTED
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_UPLINK_RD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_USER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_IP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VIRTUAL_MACHINE_REPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VLAN_TEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_RELOAD_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_CLUSTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_DATACENTER
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_EAM_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_HYPERVISOR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_BASE_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VCENTER_VRS_CONFIG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VMWARE_VRS_ADDRESS_RANGE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_DESCRIPTION
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VM_INTERFACE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VNID_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPN_CONNECT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAG
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORTTAGTEMPLATE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_GATEWAY_RESPONSE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MEDIATION_REQUEST
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_MIRROR
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPORT_TAG_BASE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VPRN_LABEL_SEQUENCENO
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VRS
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSC
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSD_COMPONENT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSG_REDUNDANT_PORT
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_VSP
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_WAN_SERVICE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE
var CONST_ASSOCIATED_APPLICATION_OBJECT_TYPE_ZONE_TEMPLATE
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENCRYPTION_INHERITED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var CONST_MAINTENANCE_MODE_DISABLED
var CONST_MAINTENANCE_MODE_ENABLED
var CONST_MAINTENANCE_MODE_ENABLED_INHERITED
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
var associated_application_id
Get associated_application_id value.
Notes: The associated application ID.
This attribute is named `associatedApplicationID` in VSD API.
var associated_application_object_id
Get associated_application_object_id value.
Notes: The associated application object ID.
This attribute is named `associatedApplicationObjectID` in VSD API.
var associated_application_object_type
Get associated_application_object_type value.
Notes: The associated application object type. Refer to API section for supported types.
This attribute is named `associatedApplicationObjectType` in VSD API.
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this zone/zone template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the zone
var dhcp_options
var encryption
Get encryption value.
Notes: Determines whether or not IPSEC is enabled.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var groups
var id
Get object id
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6
This attribute is named `IPType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var maintenance_mode
Get maintenance_mode value.
Notes: Indicates if the Zone is accepting VM activation requests.
This attribute is named `maintenanceMode` in VSD API.
var metadatas
var multicast
Get multicast value.
Notes: Indicates multicast policy on zone.
var name
Get name value.
Notes: Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the subnet defined
var number_of_hosts_in_subnets
Get number_of_hosts_in_subnets value.
Notes: Number of hosts in each of the subnets that can be created under a zone and are auto-assigned IP addresses
This attribute is named `numberOfHostsInSubnets` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var permissions
var policy_group_id
Get policy_group_id value.
Notes: PG ID for the subnet. This is unique per domain and will be in the range 1-4095
This attribute is named `policyGroupID` in VSD API.
var public_zone
Get public_zone value.
Notes: If a zone is marked as public, then it is lined to the public network associated with this data center
This attribute is named `publicZone` in VSD API.
var qoss
var statistics
var statistics_policies
var subnets
var tcas
var template_id
Get template_id value.
Notes: The ID of the template that this zone was derived from
This attribute is named `templateID` in VSD API.
var vm_interfaces
var vms
var vports
Methods
def __init__(
self, **kwargs)
Initializes a Zone instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> zone = NUZone(id=u'xxxx-xxx-xxx-xxx', name=u'Zone') >>> zone = NUZone(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a Zone instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> zone = NUZone(id=u'xxxx-xxx-xxx-xxx', name=u'Zone')
>>> zone = NUZone(data=my_dict)
"""
super(NUZone, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._maintenance_mode = None
self._name = None
self._last_updated_by = None
self._address = None
self._template_id = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._policy_group_id = None
self._associated_application_id = None
self._associated_application_object_id = None
self._associated_application_object_type = None
self._associated_multicast_channel_map_id = None
self._public_zone = None
self._multicast = None
self._number_of_hosts_in_subnets = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="maintenance_mode", remote_name="maintenanceMode", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'ENABLED_INHERITED'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="template_id", remote_name="templateID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="policy_group_id", remote_name="policyGroupID", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_id", remote_name="associatedApplicationID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_id", remote_name="associatedApplicationObjectID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="associated_application_object_type", remote_name="associatedApplicationObjectType", attribute_type=str, is_required=False, is_unique=False, choices=[u'ACLENTRY_LOCATION', u'ADDRESS_RANGE', u'ADDRESS_RANGE_STATE', u'ALARM', u'APPD_APPLICATION', u'APPD_EXTERNAL_APP_SERVICE', u'APPD_FLOW', u'APPD_FLOW_FORWARDING_POLICY', u'APPD_FLOW_SECURITY_POLICY', u'APPD_SERVICE', u'APPD_TIER', u'APPLICATION', u'AUTO_DISC_GATEWAY', u'BACK_HAUL_SERVICE_RESP', u'BGPPEER', u'BOOTSTRAP', u'BOOTSTRAP_ACTIVATION', u'BRIDGEINTERFACE', u'CERTIFICATE', u'CHILD_ENTITY_POLICY_CHANGE', u'CLOUD_MGMT_SYSTEM', u'CUSTOMER_VRF_SEQUENCENO', u'DC_CONFIG', u'DHCP_ALLOC_MESSAGE', u'DHCP_CONFIG_RESP', u'DHCP_OPTION', u'DISKSTATS', u'DOMAIN', u'DOMAIN_CONFIG', u'DOMAIN_CONFIG_RESP', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE', u'DOMAIN_FLOATING_IP_ACL_TEMPLATE_ENTRY', u'DOMAIN_TEMPLATE', u'DSCP_FORWARDING_CLASS_MAPPING', u'DSCP_FORWARDING_CLASS_TABLE', u'EGRESS_ACL', u'EGRESS_ACL_ENTRY', u'EGRESS_ACL_TEMPLATE', u'EGRESS_ACL_TEMPLATE_ENTRY', u'EGRESS_QOS_MR', u'EGRESS_QOS_PRIMITIVE', u'EGRESS_QOS_QUEUE_MR', u'ENDPOINT', u'ENTERPRISE', u'ENTERPRISE_CONFIG', u'ENTERPRISE_CONFIG_RESP', u'ENTERPRISE_NETWORK', u'ENTERPRISE_PERMISSION', u'ENTERPRISE_PROFILE', u'ENTERPRISE_SECURED_DATA', u'ENTERPRISE_SECURITY', u'ENTITY_METADATA_BINDING', u'ESI_SEQUENCENO', u'EVENT_LOG', u'EVPN_BGP_COMMUNITY_TAG_ENTRY', u'EVPN_BGP_COMMUNITY_TAG_SEQ_NO', u'EXPORTIMPORT', u'EXTERNAL_SERVICE', u'FLOATING_IP_ACL_TEMPLATE', u'FLOATING_IP_ACL_TEMPLATE_ENTRY', u'FLOATINGIP', u'FLOATINGIP_ACL', u'FLOATINGIP_ACL_ENTRY', u'GATEWAY', u'GATEWAY_CONFIG', u'GATEWAY_CONFIG_RESP', u'GATEWAY_SECURED_DATA', u'GATEWAY_SECURITY', u'GATEWAY_SECURITY_PROFILE_REQUEST', u'GATEWAY_SECURITY_PROFILE_RESPONSE', u'GATEWAY_SECURITY_REQUEST', u'GATEWAY_SECURITY_RESPONSE', u'GATEWAY_SERVICE_CONFIG', u'GATEWAY_SERVICE_CONFIG_RESP', u'GATEWAY_TEMPLATE', u'GATEWAY_VPORT_CONFIG', u'GATEWAY_VPORT_CONFIG_RESP', u'GEO_VM_EVENT', u'GEO_VM_REQ', u'GEO_VM_RES', u'GROUP', u'GROUPKEY_ENCRYPTION_PROFILE', u'HEALTH_REQ', u'HOSTINTERFACE', u'HSC', u'INFRASTRUCTURE_CONFIG', u'INFRASTRUCTURE_GATEWAY_PROFILE', u'INFRASTRUCTURE_PORT_PROFILE', u'INFRASTRUCTURE_VSC_PROFILE', u'INGRESS_ACL', u'INGRESS_ACL_ENTRY', u'INGRESS_ACL_TEMPLATE', u'INGRESS_ACL_TEMPLATE_ENTRY', u'INGRESS_ADV_FWD', u'INGRESS_ADV_FWD_ENTRY', u'INGRESS_ADV_FWD_TEMPLATE', u'INGRESS_ADV_FWD_TEMPLATE_ENTRY', u'INGRESS_EXT_SERVICE', u'INGRESS_EXT_SERVICE_ENTRY', u'INGRESS_EXT_SERVICE_TEMPLATE', u'INGRESS_EXT_SERVICE_TEMPLATE_ENTRY', u'IP_BINDING', u'JOB', u'KEYSERVER_MEMBER', u'KEYSERVER_MONITOR', u'KEYSERVER_MONITOR_ENCRYPTED_SEED', u'KEYSERVER_MONITOR_SEED', u'KEYSERVER_MONITOR_SEK', u'KEYSERVER_NOTIFICATION', u'L2DOMAIN', u'L2DOMAIN_SHARED', u'L2DOMAIN_TEMPLATE', u'LDAP_CONFIG', u'LIBVIRT_INTERFACE', u'LICENSE', u'LOCATION', u'MC_CHANNEL_MAP', u'MC_LIST', u'MC_RANGE', u'METADATA', u'METADATA_TAG', u'MIRROR_DESTINATION', u'MONITORING_PORT', u'MULTI_NIC_VPORT', u'NATMAPENTRY', u'NETWORK_ELEMENT', u'NETWORK_LAYOUT', u'NETWORK_MACRO_GROUP', u'NETWORK_POLICY_GROUP', u'NEXT_HOP_RESP', u'NODE_EXECUTION_ERROR', u'NS_REDUNDANT_PORT', u'NSG_NOTIFICATION', u'NSGATEWAY', u'NSGATEWAY_CONFIG', u'NSGATEWAY_TEMPLATE', u'NSPORT', u'NSPORT_STATIC_CONFIG', u'NSPORT_TEMPLATE', u'NSREDUNDANT_GW_GRP', u'PATCONFIG_CONFIG_RESP', u'PATNATPOOL', u'PERMISSION', u'PERMITTED_ACTION', u'POLICING_POLICY', u'POLICY_DECISION', u'POLICY_GROUP', u'POLICY_GROUP_TEMPLATE', u'PORT', u'PORT_MR', u'PORT_TEMPLATE', u'PUBLIC_NETWORK', u'QOS_PRIMITIVE', u'RATE_LIMITER', u'RD_SEQUENCENO', u'REDUNDANT_GW_GRP', u'RTRD_ENTITY', u'RTRD_SEQUENCENO', u'SERVICE_GATEWAY_RESPONSE', u'SERVICE_VRF_SEQUENCENO', u'SERVICES_GATEWAY_RESPONSE', u'SHAPING_POLICY', u'SHARED_RESOURCE', u'SITE', u'SITE_REQ', u'SITE_RES', u'STATIC_ROUTE', u'STATIC_ROUTE_RESP', u'STATISTICS', u'STATS_COLLECTOR', u'STATS_POLICY', u'STATS_TCA', u'STATSSERVER', u'SUBNET', u'SUBNET_ENTRY', u'SUBNET_MAC_ENTRY', u'SUBNET_POOL_ENTRY', u'SUBNET_TEMPLATE', u'SYSTEM_CONFIG', u'SYSTEM_CONFIG_REQ', u'SYSTEM_CONFIG_RESP', u'SYSTEM_MONITORING', u'UNSUPPORTED', u'UPLINK_RD', u'USER', u'VIRTUAL_IP', u'VIRTUAL_MACHINE', u'VIRTUAL_MACHINE_REPORT', u'VLAN', u'VLAN_TEMPLATE', u'VM_DESCRIPTION', u'VM_INTERFACE', u'VMWARE_RELOAD_CONFIG', u'VMWARE_VCENTER', u'VMWARE_VCENTER_CLUSTER', u'VMWARE_VCENTER_DATACENTER', u'VMWARE_VCENTER_EAM_CONFIG', u'VMWARE_VCENTER_HYPERVISOR', u'VMWARE_VCENTER_VRS_BASE_CONFIG', u'VMWARE_VCENTER_VRS_CONFIG', u'VMWARE_VRS_ADDRESS_RANGE', u'VNID_SEQUENCENO', u'VPN_CONNECT', u'VPORT', u'VPORT_GATEWAY_RESPONSE', u'VPORT_MEDIATION_REQUEST', u'VPORT_MIRROR', u'VPORT_TAG_BASE', u'VPORTTAG', u'VPORTTAGTEMPLATE', u'VPRN_LABEL_SEQUENCENO', u'VRS', u'VSC', u'VSD', u'VSD_COMPONENT', u'VSG_REDUNDANT_PORT', u'VSP', u'WAN_SERVICE', u'ZONE', u'ZONE_TEMPLATE'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_zone", remote_name="publicZone", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="number_of_hosts_in_subnets", remote_name="numberOfHostsInSubnets", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.tcas = NUTCAsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.permissions = NUPermissionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.dhcp_options = NUDHCPOptionsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vms = NUVMsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vm_interfaces = NUVMInterfacesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.vports = NUVPortsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.groups = NUGroupsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics = NUStatisticsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.statistics_policies = NUStatisticsPoliciesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnets = NUSubnetsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return self.template_id
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return False
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()
class NUZoneTemplate
Represents a ZoneTemplate in the VSD
Notes: As in domains and subnets, zones are derived from templates. This object provides the definition of the template.
class NUZoneTemplate(NURESTObject):
""" Represents a ZoneTemplate in the VSD
Notes:
As in domains and subnets, zones are derived from templates. This object provides the definition of the template.
"""
__rest_name__ = "zonetemplate"
__resource_name__ = "zonetemplates"
## Constants
CONST_MULTICAST_DISABLED = "DISABLED"
CONST_ENTITY_SCOPE_GLOBAL = "GLOBAL"
CONST_ENCRYPTION_DISABLED = "DISABLED"
CONST_ENCRYPTION_INHERITED = "INHERITED"
CONST_ENTITY_SCOPE_ENTERPRISE = "ENTERPRISE"
CONST_IP_TYPE_IPV6 = "IPV6"
CONST_ENCRYPTION_ENABLED = "ENABLED"
CONST_IP_TYPE_IPV4 = "IPV4"
CONST_MULTICAST_ENABLED = "ENABLED"
CONST_MULTICAST_INHERITED = "INHERITED"
def __init__(self, **kwargs):
""" Initializes a ZoneTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> zonetemplate = NUZoneTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'ZoneTemplate')
>>> zonetemplate = NUZoneTemplate(data=my_dict)
"""
super(NUZoneTemplate, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._address = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._associated_multicast_channel_map_id = None
self._public_zone = None
self._multicast = None
self._number_of_hosts_in_subnets = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_zone", remote_name="publicZone", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="number_of_hosts_in_subnets", remote_name="numberOfHostsInSubnets", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnet_templates = NUSubnetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
# Properties
@property
def ip_type(self):
""" Get ip_type value.
Notes:
IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
"""
return self._ip_type
@ip_type.setter
def ip_type(self, value):
""" Set ip_type value.
Notes:
IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
"""
self._ip_type = value
@property
def name(self):
""" Get name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
return self._name
@name.setter
def name(self, value):
""" Set name value.
Notes:
Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
"""
self._name = value
@property
def last_updated_by(self):
""" Get last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
return self._last_updated_by
@last_updated_by.setter
def last_updated_by(self, value):
""" Set last_updated_by value.
Notes:
ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
"""
self._last_updated_by = value
@property
def address(self):
""" Get address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
return self._address
@address.setter
def address(self, value):
""" Set address value.
Notes:
IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
"""
self._address = value
@property
def description(self):
""" Get description value.
Notes:
A description of the Zone template
"""
return self._description
@description.setter
def description(self, value):
""" Set description value.
Notes:
A description of the Zone template
"""
self._description = value
@property
def netmask(self):
""" Get netmask value.
Notes:
Netmask of the subnet defined
"""
return self._netmask
@netmask.setter
def netmask(self, value):
""" Set netmask value.
Notes:
Netmask of the subnet defined
"""
self._netmask = value
@property
def encryption(self):
""" Get encryption value.
Notes:
Determines whether or not IPSEC is enabled.
"""
return self._encryption
@encryption.setter
def encryption(self, value):
""" Set encryption value.
Notes:
Determines whether or not IPSEC is enabled.
"""
self._encryption = value
@property
def entity_scope(self):
""" Get entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
return self._entity_scope
@entity_scope.setter
def entity_scope(self, value):
""" Set entity_scope value.
Notes:
Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
"""
self._entity_scope = value
@property
def associated_multicast_channel_map_id(self):
""" Get associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this zone/zone template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
return self._associated_multicast_channel_map_id
@associated_multicast_channel_map_id.setter
def associated_multicast_channel_map_id(self, value):
""" Set associated_multicast_channel_map_id value.
Notes:
The ID of the Multi Cast Channel Map this zone/zone template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
"""
self._associated_multicast_channel_map_id = value
@property
def public_zone(self):
""" Get public_zone value.
Notes:
Identifies if the zone is a public zone, in which case any subnets associated with this zone are actually connected to the public subnet of the data center
This attribute is named `publicZone` in VSD API.
"""
return self._public_zone
@public_zone.setter
def public_zone(self, value):
""" Set public_zone value.
Notes:
Identifies if the zone is a public zone, in which case any subnets associated with this zone are actually connected to the public subnet of the data center
This attribute is named `publicZone` in VSD API.
"""
self._public_zone = value
@property
def multicast(self):
""" Get multicast value.
Notes:
Indicates multicast policy on zone template.
"""
return self._multicast
@multicast.setter
def multicast(self, value):
""" Set multicast value.
Notes:
Indicates multicast policy on zone template.
"""
self._multicast = value
@property
def number_of_hosts_in_subnets(self):
""" Get number_of_hosts_in_subnets value.
Notes:
Number of hosts in the subnets where IP addresses are automatically assigned from the zone IP pool
This attribute is named `numberOfHostsInSubnets` in VSD API.
"""
return self._number_of_hosts_in_subnets
@number_of_hosts_in_subnets.setter
def number_of_hosts_in_subnets(self, value):
""" Set number_of_hosts_in_subnets value.
Notes:
Number of hosts in the subnets where IP addresses are automatically assigned from the zone IP pool
This attribute is named `numberOfHostsInSubnets` in VSD API.
"""
self._number_of_hosts_in_subnets = value
@property
def external_id(self):
""" Get external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
return self._external_id
@external_id.setter
def external_id(self, value):
""" Set external_id value.
Notes:
External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
"""
self._external_id = value
## Custom methods
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
Ancestors (in MRO)
- NUZoneTemplate
- bambou.nurest_object.NURESTObject
- __builtin__.object
Class variables
var CONST_ENCRYPTION_DISABLED
var CONST_ENCRYPTION_ENABLED
var CONST_ENCRYPTION_INHERITED
var CONST_ENTITY_SCOPE_ENTERPRISE
var CONST_ENTITY_SCOPE_GLOBAL
var CONST_IP_TYPE_IPV4
var CONST_IP_TYPE_IPV6
var CONST_MULTICAST_DISABLED
var CONST_MULTICAST_ENABLED
var CONST_MULTICAST_INHERITED
var resource_name
var rest_name
Instance variables
var address
Get address value.
Notes: IP address of the subnet defined. In case of zone, this is an optional field for and allows users to allocate an IP address range to a zone. The VSD will auto-assign IP addresses to subnets from this range if a specific IP address is not defined for the subnet
var associated_multicast_channel_map_id
Get associated_multicast_channel_map_id value.
Notes: The ID of the Multi Cast Channel Map this zone/zone template is associated with. This has to be set when enableMultiCast is set to ENABLED
This attribute is named `associatedMulticastChannelMapID` in VSD API.
var children_rest_names
Gets the list of all possible children ReST names.
Returns: list: list containing all possible rest names as string
Example: >>> entity = NUEntity() >>> entity.children_rest_names ["foo", "bar"]
var creation_date
Get creation date
var description
Get description value.
Notes: A description of the Zone template
var encryption
Get encryption value.
Notes: Determines whether or not IPSEC is enabled.
var entity_scope
Get entity_scope value.
Notes: Specify if scope of entity is Data center or Enterprise level
This attribute is named `entityScope` in VSD API.
var errors
var event_logs
var external_id
Get external_id value.
Notes: External object ID. Used for integration with third party systems
This attribute is named `externalID` in VSD API.
var fetchers
Return a copy of all fetchers
Returns: list: list of all fetchers
Example:
>>> print entity.fetchers
[
var global_metadatas
var id
Get object id
var ip_type
Get ip_type value.
Notes: IPv4 or IPv6(only IPv4 is supported in R1.0) Possible values are IPV4, IPV6, .
This attribute is named `IPType` in VSD API.
var last_updated_by
Get last_updated_by value.
Notes: ID of the user who last updated the object.
This attribute is named `lastUpdatedBy` in VSD API.
var last_updated_date
Get last update date
var local_id
Get local id
var metadatas
var multicast
Get multicast value.
Notes: Indicates multicast policy on zone template.
var name
Get name value.
Notes: Name of the current entity(Zone or zone template or subnet etc..) Valid characters are alphabets, numbers, space and hyphen( - ).
var netmask
Get netmask value.
Notes: Netmask of the subnet defined
var number_of_hosts_in_subnets
Get number_of_hosts_in_subnets value.
Notes: Number of hosts in the subnets where IP addresses are automatically assigned from the zone IP pool
This attribute is named `numberOfHostsInSubnets` in VSD API.
var owner
Get owner
var parent_id
Get parent id
var parent_object
Get parent
var parent_type
Get parent type
var public_zone
Get public_zone value.
Notes: Identifies if the zone is a public zone, in which case any subnets associated with this zone are actually connected to the public subnet of the data center
This attribute is named `publicZone` in VSD API.
var qoss
var subnet_templates
Methods
def __init__(
self, **kwargs)
Initializes a ZoneTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named data will enable you to load the
object from a Python dictionary
Examples: >>> zonetemplate = NUZoneTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'ZoneTemplate') >>> zonetemplate = NUZoneTemplate(data=my_dict)
def __init__(self, **kwargs):
""" Initializes a ZoneTemplate instance
Notes:
You can specify all parameters while calling this methods.
A special argument named `data` will enable you to load the
object from a Python dictionary
Examples:
>>> zonetemplate = NUZoneTemplate(id=u'xxxx-xxx-xxx-xxx', name=u'ZoneTemplate')
>>> zonetemplate = NUZoneTemplate(data=my_dict)
"""
super(NUZoneTemplate, self).__init__()
# Read/Write Attributes
self._ip_type = None
self._name = None
self._last_updated_by = None
self._address = None
self._description = None
self._netmask = None
self._encryption = None
self._entity_scope = None
self._associated_multicast_channel_map_id = None
self._public_zone = None
self._multicast = None
self._number_of_hosts_in_subnets = None
self._external_id = None
self.expose_attribute(local_name="ip_type", remote_name="IPType", attribute_type=str, is_required=False, is_unique=False, choices=[u'IPV4', u'IPV6'])
self.expose_attribute(local_name="name", remote_name="name", attribute_type=str, is_required=True, is_unique=False)
self.expose_attribute(local_name="last_updated_by", remote_name="lastUpdatedBy", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="address", remote_name="address", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="description", remote_name="description", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="netmask", remote_name="netmask", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="encryption", remote_name="encryption", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="entity_scope", remote_name="entityScope", attribute_type=str, is_required=False, is_unique=False, choices=[u'ENTERPRISE', u'GLOBAL'])
self.expose_attribute(local_name="associated_multicast_channel_map_id", remote_name="associatedMulticastChannelMapID", attribute_type=str, is_required=False, is_unique=False)
self.expose_attribute(local_name="public_zone", remote_name="publicZone", attribute_type=bool, is_required=False, is_unique=False)
self.expose_attribute(local_name="multicast", remote_name="multicast", attribute_type=str, is_required=False, is_unique=False, choices=[u'DISABLED', u'ENABLED', u'INHERITED'])
self.expose_attribute(local_name="number_of_hosts_in_subnets", remote_name="numberOfHostsInSubnets", attribute_type=int, is_required=False, is_unique=False)
self.expose_attribute(local_name="external_id", remote_name="externalID", attribute_type=str, is_required=False, is_unique=True)
# Fetchers
self.metadatas = NUMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.global_metadatas = NUGlobalMetadatasFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.qoss = NUQOSsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.subnet_templates = NUSubnetTemplatesFetcher.fetcher_with_object(parent_object=self, relationship="child")
self.event_logs = NUEventLogsFetcher.fetcher_with_object(parent_object=self, relationship="child")
self._compute_args(**kwargs)
def add_child(
self, child)
Add a child
def add_child(self, child):
""" Add a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
if children is None:
raise InternalConsitencyError('Could not find fetcher with name %s while adding %s in parent %s' % (rest_name, child, self))
if child not in children:
child.parent_object = self
children.append(child)
def assign(
self, objects, nurest_object_type, async=False, callback=None, commit=True)
Reference a list of objects into the current resource
Args: objects (list): list of NURESTObject to link nurest_object_type (type): Type of the object to link callback (function): Callback method that should be fired at the end
Returns: Returns the current object and the connection (object, connection)
Example: >>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
def assign(self, objects, nurest_object_type, async=False, callback=None, commit=True):
""" Reference a list of objects into the current resource
Args:
objects (list): list of NURESTObject to link
nurest_object_type (type): Type of the object to link
callback (function): Callback method that should be fired at the end
Returns:
Returns the current object and the connection (object, connection)
Example:
>>> entity.assign([entity1, entity2, entity3], NUEntity) # entity1, entity2 and entity3 are now part of the entity
"""
ids = list()
for nurest_object in objects:
ids.append(nurest_object.id)
url = self.get_resource_url_for_child_type(nurest_object_type)
request = NURESTRequest(method=HTTP_METHOD_PUT, url=url, data=ids)
user_info = {'nurest_objects': objects, 'commit': commit}
if async:
return self.send_request(request=request,
async=async,
local_callback=self._did_perform_standard_operation,
remote_callback=callback,
user_info=user_info)
else:
connection = self.send_request(request=request,
user_info=user_info)
return self._did_perform_standard_operation(connection)
def copy(
self)
Returns a copy of the current object
Returns: A copy of the given object
Example::
>>> print entity.to_dict()
def copy(self):
""" Returns a copy of the current object
Returns:
A copy of the given object
Example::
>>> print entity.to_dict()
"""
return self.__class__(data=self.to_dict())
def create_child(
self, nurest_object, response_choice=None, async=False, callback=None, commit=True)
Add given nurest_object to the current object
For example, to add a child into a parent, you can call parent.create_child(nurest_object=child)
Args: nurest_object (bambou.NURESTObject): the NURESTObject object to add response_choice (int): Automatically send a response choice when confirmation is needed async (bool): should the request be done asynchronously or not callback (function): callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> entity = NUEntity(name="Super Entity") >>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
def create_child(self, nurest_object, response_choice=None, async=False, callback=None, commit=True):
""" Add given nurest_object to the current object
For example, to add a child into a parent, you can call
parent.create_child(nurest_object=child)
Args:
nurest_object (bambou.NURESTObject): the NURESTObject object to add
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): should the request be done asynchronously or not
callback (function): callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> entity = NUEntity(name="Super Entity")
>>> parent_entity.create_child(entity) # the new entity as been created in the parent_entity
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot create a child that already has an ID: %s." % nurest_object)
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def delete(
self, response_choice=1, async=False, callback=None)
Delete object and call given callback in case of call.
Args: response_choice (int): Automatically send a response choice when confirmation is needed async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.delete() # will delete the enterprise from the server
def delete(self, response_choice=1, async=False, callback=None):
""" Delete object and call given callback in case of call.
Args:
response_choice (int): Automatically send a response choice when confirmation is needed
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.delete() # will delete the enterprise from the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_DELETE, async=async, callback=callback, response_choice=response_choice)
def equals(
self, rest_object)
Compare with another object
def equals(self, rest_object):
""" Compare with another object """
if self._is_dirty:
return False
if rest_object is None:
return False
if not isinstance(rest_object, NURESTObject):
raise TypeError('The object is not a NURESTObject %s' % rest_object)
if self.rest_name != rest_object.rest_name:
return False
if self.id and rest_object.id:
return self.id == rest_object.id
if self.local_id and rest_object.local_id:
return self.local_id == rest_object.local_id
return False
def expose_attribute(
self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False)
Expose local_name as remote_name
An exposed attribute local_name will be sent within the HTTP request as
a remote_name
def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False):
""" Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name`
"""
if remote_name is None:
remote_name = local_name
if display_name is None:
display_name = local_name
attribute = NURemoteAttribute(local_name=local_name, remote_name=remote_name, attribute_type=attribute_type)
attribute.display_name = display_name
attribute.is_required = is_required
attribute.is_readonly = is_readonly
attribute.min_length = min_length
attribute.max_length = max_length
attribute.is_editable = is_editable
attribute.is_identifier = is_identifier
attribute.choices = choices
attribute.is_unique = is_unique
attribute.is_email = is_email
attribute.is_login = is_login
attribute.is_password = is_password
attribute.can_order = can_order
attribute.can_search = can_search
self._attributes[local_name] = attribute
def fetch(
self, async=False, callback=None)
Fetch all information about the current object
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Returns: tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example: >>> entity = NUEntity(id="xxx-xxx-xxx-xxx") >>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx" >>> print entity.name "My Entity"
def fetch(self, async=False, callback=None):
""" Fetch all information about the current object
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Returns:
tuple: (current_fetcher, callee_parent, fetched_bjects, connection)
Example:
>>> entity = NUEntity(id="xxx-xxx-xxx-xxx")
>>> entity.fetch() # will get the entity with id "xxx-xxx-xxx-xxx"
>>> print entity.name
"My Entity"
"""
if self.id is None:
raise InternalConsitencyError("Cannot fetch an object that does not have an ID")
request = NURESTRequest(method=HTTP_METHOD_GET, url=self.get_resource_url())
if async:
return self.send_request(request=request, async=async, local_callback=self._did_retrieve, remote_callback=callback)
else:
connection = self.send_request(request=request)
return self._did_retrieve(connection)
def fetcher_for_rest_name(
self, rest_name)
Returns the children fetcher for the given rest name
Args: rest_name (string): the children rest name
Returns: list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
def fetcher_for_rest_name(self, rest_name):
""" Returns the children fetcher for the given rest name
Args:
rest_name (string): the children rest name
Returns:
list: Returns the corresponding fetcher
Example:
>>> print entity.fetcher_for_rest_name(NUSubEntity.rest_name)
"""
if rest_name not in self._fetchers_registry:
return None
return self._fetchers_registry[rest_name]
def from_dict(
self, dictionary)
Sets all the exposed ReST attribues from the given dictionary
Args: dictionary (dict): dictionnary containing the raw object attributes and their values.
Example: >>> info = {"name": "my group", "private": False} >>> group = NUGroup() >>> group.from_dict(info) >>> print "name: %s - private: %s" % (group.name, group.private) "name: my group - private: False"
def from_dict(self, dictionary):
""" Sets all the exposed ReST attribues from the given dictionary
Args:
dictionary (dict): dictionnary containing the raw object attributes and their values.
Example:
>>> info = {"name": "my group", "private": False}
>>> group = NUGroup()
>>> group.from_dict(info)
>>> print "name: %s - private: %s" % (group.name, group.private)
"name: my group - private: False"
"""
for remote_name, remote_value in dictionary.iteritems():
# Check if a local attribute is exposed with the remote_name
# if no attribute is exposed, return None
local_name = next((name for name, attribute in self._attributes.iteritems() if attribute.remote_name == remote_name), None)
if local_name:
setattr(self, local_name, remote_value)
else:
# print('Attribute %s could not be added to object %s' % (remote_name, self))
pass # pragma: no cover
def genealogic_ids(
self)
Get all genealogic ids
Returns: A list of all parent ids
def genealogic_ids(self):
""" Get all genealogic ids
Returns:
A list of all parent ids
"""
ids = []
parent = self
while parent:
ids.append(parent.id)
parent = parent.parent_object
return ids
def genealogic_types(
self)
Get genealogic types
Returns: Returns a list of all parent types
def genealogic_types(self):
""" Get genealogic types
Returns:
Returns a list of all parent types
"""
types = []
parent = self
while parent:
types.append(parent.rest_name)
parent = parent.parent_object
return types
def genealogy_contains_id(
self, id)
Check if parents contains an object of type resource_name
Args: id: the id of the resource to find
Returns: Returns True if a parent with specific id has been found. False otherwise.
def genealogy_contains_id(self, id):
""" Check if parents contains an object of type resource_name
Args:
id: the id of the resource to find
Returns:
Returns True if a parent with specific id has been found. False otherwise.
"""
ids = self.genealogic_ids()
return id in ids
def genealogy_contains_type(
self, resource_name)
Check if parents contains an object of type resource_name
Args: resource_name: the name of the resource to find
Returns: Returns True if a parent of type has been found. False otherwise.
def genealogy_contains_type(self, resource_name):
""" Check if parents contains an object of type resource_name
Args:
resource_name: the name of the resource to find
Returns:
Returns True if a parent of type has been found. False otherwise.
"""
resource_names = self.genealogic_types()
return resource_name in resource_names
def get_attribute_infos(
self, local_name)
Get exposed attribute information
Args: local_name: the attribute name
Returns: A dictionary of all information
def get_attribute_infos(self, local_name):
""" Get exposed attribute information
Args:
local_name: the attribute name
Returns:
A dictionary of all information
"""
if local_name in self._attributes:
return self._attributes[local_name]
return None
def get_attributes(
self)
Get all attributes information
Returns: Returns a dictionnary containing attribute information
def get_attributes(self):
""" Get all attributes information
Returns:
Returns a dictionnary containing attribute information
"""
return self._attributes.values()
def get_formated_creation_date(
self, format='%b %Y %d %H:%I:%S')
Return creation date with a given format. Default is '%b %Y %d %H:%I:%S'
def get_formated_creation_date(self, format='%b %Y %d %H:%I:%S'):
""" Return creation date with a given format. Default is '%b %Y %d %H:%I:%S' """
if not self._creation_date:
return None
date = datetime.datetime.utcfromtimestamp(self._creation_date)
return date.strftime(format)
def get_resource_url(
self)
Get resource complete url
def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
if self.id is not None:
return "%s/%s/%s" % (url, name, self.id)
return "%s/%s" % (url, name)
def get_resource_url_for_child_type(
self, nurest_object_type)
Get the resource url for the nurest_object type
def get_resource_url_for_child_type(self, nurest_object_type):
""" Get the resource url for the nurest_object type """
return "%s/%s" % (self.get_resource_url(), nurest_object_type.resource_name)
def instantiate_child(
self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True)
Instantiate an nurest_object from a template object
Args: nurest_object: the NURESTObject object to add from_template: the NURESTObject template object callback: callback containing the object and the connection
Returns: Returns the object and connection (object, connection)
Example: >>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one) >>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one) >>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template >>> >>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
def instantiate_child(self, nurest_object, from_template, response_choice=None, async=False, callback=None, commit=True):
""" Instantiate an nurest_object from a template object
Args:
nurest_object: the NURESTObject object to add
from_template: the NURESTObject template object
callback: callback containing the object and the connection
Returns:
Returns the object and connection (object, connection)
Example:
>>> parent_entity = NUParentEntity(id="xxxx-xxxx-xxx-xxxx") # create a NUParentEntity with an existing ID (or retrieve one)
>>> other_entity_template = NUOtherEntityTemplate(id="yyyy-yyyy-yyyy-yyyy") # create a NUOtherEntityTemplate with an existing ID (or retrieve one)
>>> other_entity_instance = NUOtherEntityInstance(name="my new instance") # create a new NUOtherEntityInstance to be intantiated from other_entity_template
>>>
>>> parent_entity.instantiate_child(other_entity_instance, other_entity_template) # instatiate the new domain in the server
"""
# if nurest_object.id:
# raise InternalConsitencyError("Cannot instantiate a child that already has an ID: %s." % nurest_object)
if not from_template.id:
raise InternalConsitencyError("Cannot instantiate a child from a template with no ID: %s." % from_template)
nurest_object.template_id = from_template.id
return self._manage_child_object(nurest_object=nurest_object,
async=async,
method=HTTP_METHOD_POST,
callback=callback,
handler=self._did_create_child,
response_choice=response_choice,
commit=commit)
def is_from_template(
self)
Verify if the object has been instantiated from a template
Note: The object has to be fetched. Otherwise, it does not have information from its parent
Returns: (bool): True if the object is a template
def is_from_template(self):
""" Verify if the object has been instantiated from a template
Note:
The object has to be fetched. Otherwise, it does not
have information from its parent
Returns:
(bool): True if the object is a template
"""
return False
def is_owned_by_current_user(
self)
Check if the current user owns the object
def is_owned_by_current_user(self):
""" Check if the current user owns the object """
from bambou.nurest_root_object import NURESTRootObject
root_object = NURESTRootObject.get_default_root_object()
return self._owner == root_object.id
def is_template(
self)
Verify that the object is a template
Returns: (bool): True if the object is a template
def is_template(self):
""" Verify that the object is a template
Returns:
(bool): True if the object is a template
"""
return True
def is_valid(
self)
def is_valid(self):
"""
"""
return len(self.errors) == 0
def object_with_id(
cls, id)
Get a new object with the given id
Returns: Returns a new instance with specified id
@classmethod
def object_with_id(cls, id):
""" Get a new object with the given id
Returns:
Returns a new instance with specified id
"""
new_object = cls()
new_object.id = id
return new_object
def parent_for_matching_rest_name(
self, rest_names)
Return parent that matches a rest name
def parent_for_matching_rest_name(self, rest_names):
""" Return parent that matches a rest name """
parent = self
while parent:
if parent.rest_name in rest_names:
return parent
parent = parent.parent_object
return None
def register_fetcher(
self, fetcher, rest_name)
Register a children fetcher
def register_fetcher(self, fetcher, rest_name):
""" Register a children fetcher
"""
self._fetchers_registry[rest_name] = fetcher
def remove_child(
self, child)
Remove a child
def remove_child(self, child):
""" Remove a child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
target_child = None
for local_child in children:
if local_child.id == child.id:
target_child = local_child
break
if target_child:
target_child.parent_object = None
children.remove(target_child)
def rest_base_url(
cls)
Override this method to set object base url
@classmethod
def rest_base_url(cls):
""" Override this method to set object base url """
controller = _NURESTSessionCurrentContext.session.login_controller
return controller.url
def rest_equals(
self, rest_object)
Compare objects REST attributes
def rest_equals(self, rest_object):
""" Compare objects REST attributes
"""
if not self.equals(rest_object):
return False
return self.to_dict() == rest_object.to_dict()
def save(
self, response_choice=None, async=False, callback=None)
Update object and call given callback in case of async call
Args: async (bool): Boolean to make an asynchronous call. Default is False callback (function): Callback method that will be triggered in case of asynchronous call
Example: >>> entity.name = "My Super Object" >>> entity.save() # will save the new name in the server
def save(self, response_choice=None, async=False, callback=None):
""" Update object and call given callback in case of async call
Args:
async (bool): Boolean to make an asynchronous call. Default is False
callback (function): Callback method that will be triggered in case of asynchronous call
Example:
>>> entity.name = "My Super Object"
>>> entity.save() # will save the new name in the server
"""
return self._manage_child_object(nurest_object=self, method=HTTP_METHOD_PUT, async=async, callback=callback, response_choice=response_choice)
def send_request(
self, request, async=False, local_callback=None, remote_callback=None, user_info=None)
Sends a request, calls the local callback, then the remote callback in case of async call
Args: request: The request to send local_callback: local method that will be triggered in case of async call remote_callback: remote moethd that will be triggered in case of async call user_info: contains additionnal information to carry during the request
Returns: Returns the object and connection (object, connection)
def send_request(self, request, async=False, local_callback=None, remote_callback=None, user_info=None):
""" Sends a request, calls the local callback, then the remote callback in case of async call
Args:
request: The request to send
local_callback: local method that will be triggered in case of async call
remote_callback: remote moethd that will be triggered in case of async call
user_info: contains additionnal information to carry during the request
Returns:
Returns the object and connection (object, connection)
"""
callbacks = dict()
if local_callback:
callbacks['local'] = local_callback
if remote_callback:
callbacks['remote'] = remote_callback
connection = NURESTConnection(request=request, async=async, callback=self._did_receive_response, callbacks=callbacks)
connection.user_info = user_info
return connection.start()
def to_dict(
self)
Converts the current object into a Dictionary using all exposed ReST attributes.
Returns: dict: the dictionary containing all the exposed ReST attributes and their values.
Example:: >>> print entity.to_dict() {"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
def to_dict(self):
""" Converts the current object into a Dictionary using all exposed ReST attributes.
Returns:
dict: the dictionary containing all the exposed ReST attributes and their values.
Example::
>>> print entity.to_dict()
{"name": "my entity", "description": "Hello World", "ID": "xxxx-xxx-xxxx-xxx", ...}
"""
dictionary = dict()
for local_name, attribute in self._attributes.iteritems():
remote_name = attribute.remote_name
if hasattr(self, local_name):
value = getattr(self, local_name)
# Removed to resolve issue http://mvjira.mv.usa.alcatel.com/browse/VSD-5940 (12/15/2014)
# if isinstance(value, bool):
# value = int(value)
if isinstance(value, NURESTObject):
value = value.to_dict()
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], NURESTObject):
tmp = list()
for obj in value:
tmp.append(obj.to_dict())
value = tmp
dictionary[remote_name] = value
else:
pass # pragma: no cover
return dictionary
def update_child(
self, child)
Update child
def update_child(self, child):
""" Update child """
rest_name = child.rest_name
children = self.fetcher_for_rest_name(rest_name)
index = None
for local_child in children:
if local_child.id == child.id:
index = children.index(local_child)
break
if index is not None:
children[index] = child
def validate(
self)
Validate the current object attributes.
Check all attributes and store errors
Returns: Returns True if all attibutes of the object respect contraints. Returns False otherwise and store error in errors dict.
def validate(self):
""" Validate the current object attributes.
Check all attributes and store errors
Returns:
Returns True if all attibutes of the object
respect contraints. Returns False otherwise and
store error in errors dict.
"""
self._attribute_errors = dict() # Reset validation errors
for local_name, attribute in self._attributes.iteritems():
value = getattr(self, local_name, None)
if attribute.is_required and (value is None or value == ""):
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'This value is mandatory.',
'remote_name': attribute.remote_name}
continue
if value is None:
continue # without error
if type(value) != attribute.attribute_type:
if attribute.attribute_type != str or type(value) != unicode:
self._attribute_errors[local_name] = {'title': 'Wrong type',
'description': 'Attribute %s type should be %s but is %s' % (attribute.remote_name, attribute.attribute_type, type(value)),
'remote_name': attribute.remote_name}
continue
if attribute.min_length and len(value) < attribute.min_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s minimum size should be %s but is %s' % (attribute.remote_name, attribute.min_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.max_length and len(value) > attribute.max_length:
self._attribute_errors[local_name] = {'title': 'Invalid lenght',
'description': 'Attribute %s maximum size should be %s but is %s' % (attribute.remote_name, attribute.max_length, len(value)),
'remote_name': attribute.remote_name}
continue
if attribute.choices and value not in attribute.choices:
self._attribute_errors[local_name] = {'title': 'Invalid input',
'description': 'Invalid input',
'remote_name': attribute.remote_name}
continue
return self.is_valid()